diff options
author | Teddy Wing | 2021-03-13 21:25:20 +0100 |
---|---|---|
committer | Teddy Wing | 2021-03-13 21:25:20 +0100 |
commit | e99d57d6cdb8760d4351c9f0ed9f5b0285b26e37 (patch) | |
tree | df35502fcffbb74dde59179b7262fca3315490ef /src | |
parent | 9d9a69973193597bf6c08822a96a851c9660d6d0 (diff) | |
download | mutt-ottolangy-e99d57d6cdb8760d4351c9f0ed9f5b0285b26e37.tar.bz2 |
Replace `unwrap`s with try in non-main functions
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/main.rs b/src/main.rs index d98d998..45d4820 100644 --- a/src/main.rs +++ b/src/main.rs @@ -40,10 +40,10 @@ fn main() { } fn get_email_body(email: &[u8]) -> Result<String, Box<dyn Error>> { - let email = mailparse::parse_mail(&email).unwrap(); + let email = mailparse::parse_mail(&email)?; if email.subparts.is_empty() { - let body = email.get_body().unwrap(); + let body = email.get_body()?; return Ok(body); } else { @@ -54,7 +54,7 @@ fn get_email_body(email: &[u8]) -> Result<String, Box<dyn Error>> { if header.get_key() == "Content-Type" && header.get_value().starts_with("text/plain") { - return Ok(part.get_body().unwrap()); + return Ok(part.get_body()?); } } } @@ -64,12 +64,12 @@ fn get_email_body(email: &[u8]) -> Result<String, Box<dyn Error>> { } fn write_attribution(config: &str) -> Result<(), Box<dyn Error>> { - let xdg_dirs = xdg::BaseDirectories::with_prefix(PROGRAM_NAME).unwrap(); + let xdg_dirs = xdg::BaseDirectories::with_prefix(PROGRAM_NAME)?; - let muttrc_path = xdg_dirs.place_data_file(MUTTRC_FILENAME).unwrap(); + let muttrc_path = xdg_dirs.place_data_file(MUTTRC_FILENAME)?; - let mut file = File::create(muttrc_path).unwrap(); - file.write_all(config.as_bytes()).unwrap(); + let mut file = File::create(muttrc_path)?; + file.write_all(config.as_bytes())?; Ok(()) } |