summaryrefslogtreecommitdiffstats
path: root/src/panic
diff options
context:
space:
mode:
Diffstat (limited to 'src/panic')
-rw-r--r--src/panic/Cargo.toml6
-rw-r--r--src/panic/src/main.rs23
2 files changed, 29 insertions, 0 deletions
diff --git a/src/panic/Cargo.toml b/src/panic/Cargo.toml
new file mode 100644
index 0000000..94b8cff
--- /dev/null
+++ b/src/panic/Cargo.toml
@@ -0,0 +1,6 @@
+[package]
+name = "panic"
+version = "0.1.0"
+edition = "2024"
+
+[dependencies]
diff --git a/src/panic/src/main.rs b/src/panic/src/main.rs
new file mode 100644
index 0000000..bf8be55
--- /dev/null
+++ b/src/panic/src/main.rs
@@ -0,0 +1,23 @@
+struct Test <T> {
+ a: T,
+ b: T,
+}
+
+#![allow(unused)]
+fn main() {
+ use std::fs::File;
+ use std::io::{self, Read};
+
+ fn read_username_from_file() -> Result<String, io::Error> {
+ let username_file_result = File::open("/tmp/hello.txt");
+
+ let mut username_file = username_file_result?;
+
+ let mut username = String::new();
+
+ username_file.read_to_string(&mut username)?;
+ Ok(username)
+ }
+
+ println!("username: {}", read_username_from_file().unwrap());
+}