rust
fn main() {
match is_ok() {
Ok(text) => println!("Ok: {}", text),
Err(e) => println!("Error: {}", e),
}
match is_err() {
Ok(text) => println!("Ok: {}", text),
Err(e) => println!("Error: {}", e),
}
}
fn is_ok() -> Result<String, &'static str> {
Ok("it worked".to_string())
}
fn is_err() -> Result<String, &'static str> {
Err("it failed")
}
results start
This was a quick test to make sure I'm getting
the basics of Rust's Result enum type. I tried
to do this in an actual app but kept getting
errors saying "expected 1 generic argument",
"supplied 2 generic arguments".