From 256ad69edea8bb5eeff38e3f5fa1dcf6e990daf7 Mon Sep 17 00:00:00 2001 From: hybrid Date: Fri, 16 Oct 2026 12:37:15 +0300 Subject: add: generics, panic --- src/panic/Cargo.toml | 6 ++++++ src/panic/src/main.rs | 23 +++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 src/panic/Cargo.toml create mode 100644 src/panic/src/main.rs (limited to 'src/panic') 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 { + a: T, + b: T, +} + +#![allow(unused)] +fn main() { + use std::fs::File; + use std::io::{self, Read}; + + fn read_username_from_file() -> Result { + 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()); +} -- cgit v1.3.1