Rust operators: Difference between revisions

From wikinotes
Line 5: Line 5:


= Result Operators =
= Result Operators =
<blockquote>
== result? ==
<blockquote>
<blockquote>
<syntaxhighlight lang="rust">
<syntaxhighlight lang="rust">
Line 13: Line 15:
}
}
</syntaxhighlight>
</syntaxhighlight>
</blockquote><!-- ? -->
</blockquote><!-- Result Operators -->
</blockquote><!-- Result Operators -->



Revision as of 04:52, 11 February 2023

Arithmetic

Result Operators

result?

// bind 'Ok-val' to bar,
// if 'Err-val', return-early with Err(Err-val)
fn foo() -> Result<_, _> {
    let bar = get_result()?;
}

Operator Overloading