@@ -277,16 +277,22 @@ This will compile without error.
277277This means that even if someone does something bad like add methods to ` i32 ` ,
278278it won’t affect you, unless you ` use ` that trait.
279279
280- There’s one more restriction on implementing traits: either the trait, or the
281- type you’re writing the ` impl ` for, must be defined by you. So, we could
282- implement the ` HasArea ` type for ` i32 ` , because ` HasArea ` is in our code. But
283- if we tried to implement ` ToString ` , a trait provided by Rust, for ` i32 ` , we could
284- not, because neither the trait nor the type are in our code.
280+ There’s one more restriction on implementing traits: either the trait
281+ or the type you’re implementing it for must be defined by you. Or more
282+ precisely, one of them must be defined in the same crate as the ` impl `
283+ you're writing. For more on Rust's module and package system, see the
284+ chapter on [ crates and modules] [ cm ] .
285+
286+ So, we could implement the ` HasArea ` type for ` i32 ` , because we defined
287+ ` HasArea ` in our code. But if we tried to implement ` ToString ` , a trait
288+ provided by Rust, for ` i32 ` , we could not, because neither the trait nor
289+ the type are defined in our crate.
285290
286291One last thing about traits: generic functions with a trait bound use
287292‘monomorphization’ (mono: one, morph: form), so they are statically dispatched.
288293What’s that mean? Check out the chapter on [ trait objects] [ to ] for more details.
289294
295+ [ cm ] : crates-and-modules.html
290296[ to ] : trait-objects.html
291297
292298# Multiple trait bounds
0 commit comments