refactor: remove some easy to remove unwrap() calls

This commit is contained in:
link2xt
2025-11-19 11:59:24 +00:00
committed by l
parent b4cd99fc56
commit 849cde9757
3 changed files with 7 additions and 6 deletions

View File

@@ -525,7 +525,7 @@ async fn configure(ctx: &Context, param: &EnteredLoginParam) -> Result<Option<&'
progress!(ctx, 850);
// Wait for SMTP configuration
smtp_config_task.await.unwrap()?;
smtp_config_task.await??;
progress!(ctx, 900);

View File

@@ -679,8 +679,9 @@ impl MimeMessage {
fn parse_system_message_headers(&mut self, context: &Context) {
if self.get_header(HeaderDef::AutocryptSetupMessage).is_some() && !self.incoming {
self.parts.retain(|part| {
part.mimetype.is_none()
|| part.mimetype.as_ref().unwrap().as_ref() == MIME_AC_SETUP_FILE
part.mimetype
.as_ref()
.is_none_or(|mimetype| mimetype.as_ref() == MIME_AC_SETUP_FILE)
});
if self.parts.len() == 1 {

View File

@@ -145,14 +145,14 @@ impl SchedulerState {
InnerSchedulerState::Started(_) => {
let new_state = InnerSchedulerState::Paused {
started: true,
pause_guards_count: NonZeroUsize::new(1).unwrap(),
pause_guards_count: NonZeroUsize::MIN,
};
Self::do_stop(&mut inner, context, new_state).await;
}
InnerSchedulerState::Stopped => {
*inner = InnerSchedulerState::Paused {
started: false,
pause_guards_count: NonZeroUsize::new(1).unwrap(),
pause_guards_count: NonZeroUsize::MIN,
};
}
InnerSchedulerState::Paused {
@@ -183,7 +183,7 @@ impl SchedulerState {
ref started,
ref mut pause_guards_count,
} => {
if *pause_guards_count == NonZeroUsize::new(1).unwrap() {
if *pause_guards_count == NonZeroUsize::MIN {
match *started {
true => SchedulerState::do_start(&mut inner, &context).await,
false => *inner = InnerSchedulerState::Stopped,