1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-04-12 20:21:56 +02:00

Use type annotation instead of turbo fish in method chapter ()

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:
Martin Huschenbett 2023-12-06 15:16:01 +01:00 committed by GitHub
parent 70efef4f38
commit f08c537007
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -31,7 +31,7 @@ impl Race {
}
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);
}
}