Texonom
Texonom
/
Engineering
Engineering
/Software Engineering/Programming/Programming Language/Programming Languages/4GL/Rust/Rust Grammar/Rust Keyword/
Rust return Keyword
Search

Rust return Keyword

Creator
Creator
Seonglae Cho
Created
Created
2022 Jun 16 3:20
Editor
Editor
Seonglae Cho
Edited
Edited
2022 Jun 16 5:21
Refs
Refs
 
 
 
 
 
Why is using return as the last statement in a function considered bad style?
I was reading through the Rust documentation and came across the following example and statement Using a return as the last line of a function works, but is considered poor style: fn foo(x: i32) ...
Why is using return as the last statement in a function considered bad style?
https://stackoverflow.com/questions/27961879/why-is-using-return-as-the-last-statement-in-a-function-considered-bad-style
Why is using return as the last statement in a function considered bad style?
return - Rust
Return a value from a function. A return marks the end of an execution path in a function: return is not needed when the returned value is the last expression in the function. In this case the; is omitted: return returns from the function immediately (an "early return"):
https://doc.rust-lang.org/std/keyword.return.html
 
 

Recommendations

Texonom
Texonom
/
Engineering
Engineering
/Software Engineering/Programming/Programming Language/Programming Languages/4GL/Rust/Rust Grammar/Rust Keyword/
Rust return Keyword
Copyright Seonglae Cho