From ace046624d2e23fba67564a86af7f03ed8a48eae Mon Sep 17 00:00:00 2001 From: Freya Murphy Date: Thu, 29 Feb 2024 21:05:10 -0500 Subject: remove unwraps, fix utf8 --- matrix-std/src/io.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'matrix-std/src/io.rs') diff --git a/matrix-std/src/io.rs b/matrix-std/src/io.rs index 19ff074..829ed28 100644 --- a/matrix-std/src/io.rs +++ b/matrix-std/src/io.rs @@ -106,7 +106,7 @@ fn file_read(_: VmArgs, args: Vec) -> Result { return error!("file read requires a file") }; let mut contents = String::new(); - if let Err(err) = file.try_borrow_mut().unwrap().read_to_string(&mut contents) { + if let Err(err) = file.borrow_mut().read_to_string(&mut contents) { return error!("cannot read file: '{err}'") }; Ok(Value::String(contents.into())) @@ -119,7 +119,7 @@ fn file_lines(_: VmArgs, args: Vec) -> Result { return error!("file read requires a file") }; let mut contents = String::new(); - if let Err(err) = file.try_borrow_mut().unwrap().read_to_string(&mut contents) { + if let Err(err) = file.borrow_mut().read_to_string(&mut contents) { return error!("cannot read file: '{err}'") }; let lines: Vec> = contents.split_inclusive("\n").map(|s| Rc::from(s)).collect(); @@ -139,7 +139,7 @@ fn file_write(_: VmArgs, args: Vec) -> Result { return error!("file write requires a file") }; let content = format!("{content}"); - if let Err(err) = file.try_borrow_mut().unwrap().write_all(content.as_bytes()) { + if let Err(err) = file.borrow_mut().write_all(content.as_bytes()) { return error!("cannot write file: '{err}'") }; Ok(Value::Nil) -- cgit v1.2.3-freya