Rust operators: Difference between revisions
From wikinotes
(Created page with "= Arithmetic = <blockquote> </blockquote><!-- Arithmetic --> = Result Operators = <blockquote> <syntaxhighlight lang="rust"> let foo = get_result()?; // bind 'Ok-val' to foo, if 'Err-val', return-early with Err(Err-val) </syntaxhighlight> </blockquote><!-- Result Operators --> = Operator Overloading = <blockquote> </blockquote><!-- Operator Overloading -->") |
|||
Line 7: | Line 7: | ||
<blockquote> | <blockquote> | ||
<syntaxhighlight lang="rust"> | <syntaxhighlight lang="rust"> | ||
// bind 'Ok-val' to bar, | |||
// if 'Err-val', return-early with Err(Err-val) | |||
fn foo() -> Result<_, _> { | |||
let bar = get_result()?; | |||
} | |||
</syntaxhighlight> | </syntaxhighlight> | ||
</blockquote><!-- Result Operators --> | </blockquote><!-- Result Operators --> |
Revision as of 04:52, 11 February 2023
Arithmetic
Result Operators
// bind 'Ok-val' to bar, // if 'Err-val', return-early with Err(Err-val) fn foo() -> Result<_, _> { let bar = get_result()?; }