Compare commits
5 Commits
04520ffa1e
...
019fbcf095
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
019fbcf095 | ||
|
|
20c675ef91 | ||
|
|
6e0e031b12 | ||
|
|
d5427c96ca | ||
|
|
092e5693b7 |
15
src/main.rs
15
src/main.rs
@ -1,5 +1,14 @@
|
||||
fn add_10(value: Option<u32>) -> Result<u32, String> {
|
||||
match value {
|
||||
Some(v) => Ok(v + 10),
|
||||
None => Err(String::from("value was empty")),
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
for value in (-10..10).rev() {
|
||||
println!("Value: {}", value);
|
||||
}
|
||||
let value = add_10(None);
|
||||
|
||||
println!("Result is: {}", value.unwrap_or(42));
|
||||
|
||||
panic!("Non recoverable error.");
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user