mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-04-24 16:42:36 +02:00
Use type annotation instead of turbo fish in method chapter (#1558)
If we use a type annotation, we get around explaining the turbo fish, which isn't trivial without having introduced generics. Type annotations on the other hand are known already.
This commit is contained in:
parent
70efef4f38
commit
f08c537007
@ -31,7 +31,7 @@ impl Race {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn finish(self) { // Exclusive ownership of self
|
fn finish(self) { // Exclusive ownership of self
|
||||||
let total = self.laps.iter().sum::<i32>();
|
let total: i32 = self.laps.iter().sum();
|
||||||
println!("Race {} is finished, total lap time: {}", self.name, total);
|
println!("Race {} is finished, total lap time: {}", self.name, total);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user