Result struct
Basic Usage
fn divide(num1: u32, num2: u32) -> Result<u32, String> {
if num2 == 0 {
return Err(String::from("You can't divide by 0"));
}
return Ok(num1 / num2);
}
fn main() {
let result = divide(6, 0);
if result.is_ok() {
println!("This is the happy path: {}", result.unwrap())
} else {
println!("This is the error: {}", result.err().unwrap())
}
}The Shortcut
In Substreams
Last updated
Was this helpful?

