From a2483d23d5b06522579225c735de9072e40bb0f1 Mon Sep 17 00:00:00 2001 From: Fredrik Klingenberg Date: Mon, 1 Apr 2024 14:42:15 +0200 Subject: [PATCH] feat: ? operator chainging Signed-off-by: Fredrik Klingenberg --- projects/panic/src/main.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/projects/panic/src/main.rs b/projects/panic/src/main.rs index 6820a48..cb2c08b 100644 --- a/projects/panic/src/main.rs +++ b/projects/panic/src/main.rs @@ -26,3 +26,9 @@ fn read_username_from_file() -> Result { username_file.read_to_string(&mut username)?; Ok(username) } + +fn read_username_from_file_simplified() -> Result{ + let mut username = String::new(); + File::open("hello.txt")?.read_to_string(&mut username)?; + Ok(username) +}