mirror of https://github.com/rust-lang/book
Remove superfluous return
Making it arguably more idiomatic and being consistent. See also: https://doc.rust-lang.org/book/functions.html#early-returns
This commit is contained in:
parent
0b72a2a4f5
commit
e9c617bda5
|
@ -83,7 +83,7 @@ A more concrete example:
|
|||
fn main() {
|
||||
// Don't worry if you don't understand how `fold` works, the point here is that an immutable reference is borrowed.
|
||||
fn sum_vec(v: &Vec<i32>) -> i32 {
|
||||
return v.iter().fold(0, |a, &b| a + b);
|
||||
v.iter().fold(0, |a, &b| a + b)
|
||||
}
|
||||
// Borrow two vectors and sum them.
|
||||
// This kind of borrowing does not allow mutation through the borrowed reference.
|
||||
|
|
Loading…
Reference in New Issue