January 2019
Beginner to intermediate
554 pages
13h 31m
English
We can specify trait bounds on types too:
// trait_bounds_types.rsuse std::fmt::Display;struct Foo<T: Display> { bar: T}// orstruct Bar<F> where F: Display { inner: F}fn main() {}
However, trait bounds on types are discouraged as it places restrictions on types themselves. Generally, we want types to be as generic as possible, allowing us to create instances using any type, and instead place restrictions on their behavior using traits bounds in functions or methods.
Read now
Unlock full access