mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-27 11:16:03 +00:00
Replace try! with ?
This commit is contained in:
parent
0ff96c5ea9
commit
514751ff8a
@ -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
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -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: \
|
||||||
|
Loading…
Reference in New Issue
Block a user