std-method
Result::and
Return the second result on first success or keep the first failure. The second argument is already evaluated, so use and_then for conditional execution. Expected stdout (not executed): Ok("done") Common mistake: Assuming and prevents the second operation from running.
Formal Syntax & Structure
rust syntaxrust
fn and<U>(self, res: Result<U, E>) -> Result<U, E>Working Example
Example Snippetrust
fn main() { let first: Result<i32, &str> = Ok(1); println!("{:?}", first.and(Ok("done")));}