Replace try! with ?

This commit is contained in:
Alexandre Bury 2018-12-17 14:02:29 -08:00
parent 0ff96c5ea9
commit 514751ff8a
2 changed files with 3 additions and 4 deletions

View File

@ -239,8 +239,8 @@ impl From<toml::de::Error> for Error {
pub fn load_theme_file<P: AsRef<Path>>(filename: P) -> Result<Theme, Error> { pub fn load_theme_file<P: AsRef<Path>>(filename: P) -> Result<Theme, Error> {
let content = { let content = {
let mut content = String::new(); let mut content = String::new();
let mut file = try!(File::open(filename)); let mut file = File::open(filename)?;
try!(file.read_to_string(&mut content)); file.read_to_string(&mut content)?;
content content
}; };

View File

@ -30,8 +30,7 @@ where
// We already have one byte, now read the others. // We already have one byte, now read the others.
for _ in 1..n_bytes { for _ in 1..n_bytes {
let byte = let byte = next().ok_or_else(|| "Missing UTF-8 byte".to_string())?;
try!(next().ok_or_else(|| "Missing UTF-8 byte".to_string()));
if byte & 0xC0 != 0x80 { if byte & 0xC0 != 0x80 {
return Err(format!( return Err(format!(
"Found non-continuation byte after leading: \ "Found non-continuation byte after leading: \