Commit fa0e650 1 parent 62a8c6f commit fa0e650 Copy full SHA for fa0e650
File tree 1 file changed +6
-6
lines changed
1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -610,12 +610,12 @@ reduce duplication but also specify to the compiler that we want the generic
610
610
type to have particular behavior. The compiler can then use the trait bound
611
611
information to check that all the concrete types used with our code provide the
612
612
correct behavior. In dynamically typed languages, we would get an error at
613
- runtime if we called a method on a type that the type didn’t implement. But
614
- Rust moves these errors to compile time so we’re forced to fix the problems
615
- before our code is even able to run. Additionally, we don’t have to write code
616
- that checks for behavior at runtime because we’ve already checked at compile
617
- time. Doing so improves performance without having to give up the flexibility
618
- of generics.
613
+ runtime if we called a method on a type which didn’t implement the trait which
614
+ defines the method. But Rust moves these errors to compile time so we’re forced
615
+ to fix the problems before our code is even able to run. Additionally, we don’t
616
+ have to write code that checks for behavior at runtime because we’ve already
617
+ checked at compile time. Doing so improves performance without having to give
618
+ up the flexibility of generics.
619
619
620
620
Another kind of generic that we’ve already been using is called * lifetimes* .
621
621
Rather than ensuring that a type has the behavior we want, lifetimes ensure
You can’t perform that action at this time.
0 commit comments