Rust Cargo Development Tutorials, Guides & Insights
Unlock 1+ expert-curated rust cargo tutorials, real-world code snippets, and modern dev strategies. From fundamentals to advanced topics, boost your rust cargo skills on DeveloperBreeze.
Adblocker Detected
It looks like you're using an adblocker. Our website relies on ads to keep running. Please consider disabling your adblocker to support us and access the content.
Rust Cheatsheet
Cheatsheet August 29, 2024
rust
fn main() {
panic!("Crash and burn");
}
use std::fs::File;
use std::io::ErrorKind;
fn main() {
let f = File::open("hello.txt");
let f = match f {
Ok(file) => file,
Err(ref error) if error.kind() == ErrorKind::NotFound => {
match File::create("hello.txt") {
Ok(fc) => fc,
Err(e) => panic!("Problem creating the file: {:?}", e),
}
},
Err(error) => {
panic!("Problem opening the file: {:?}", error)
},
};
}