Loading tutorials
&T), implement a trait for a type, and work with Option and slices. It covers how to declare a generic function, how the compiler picks the concrete types, and the errors you will meet first.4 min read&T, how to implement a trait, and how to use Option, Result, and Vec. It also assumes you have seen a generic function such as fn largest<T: PartialOrd>(items: &[T]) -> &T. Here the same idea moves from functions4 min readOption and Vec. You should also have seen a generic function such as fn first<T>(items: &[T]) -> &T.4 min readT: Display. It also assumes you have used Iterator and IntoIterator at a basic level. Here you will learn the where clause: what it means, when it is only a style c5 min readPoint<T>, you know the T: Trait bound syntax, and you can implement a trait for a type. It covers how to write methods for generic types, and how to give some instantiations methods that others lack.4 min readT and &T. It explains what the compiler produces from that code, and why it is fast but can make binaries larger.5 min readfn f<T: Display>(x: T). It also assumes you know what a closure is and how Iterator adapters like map and filter work. impl Trait is a shorter way to write some generics, and in return position it does somethi6 min readT: Trait) resolve which implementation to call at compile time. Trait objects (dyn Trait) resolve it at run time. This chapter explains how each one works, what each costs, and how to choose between th5 min readOption<&T> signatures. Generic type parameters (<T>) should already feel familiar. Here you will learn the other way a trait can mention a type: a type that each implementor chooses 5 min readimpl<T: Bound> Type<T> blocks. If any of that is shaky, review trait bounds and generic impl blocks first.4 min readimpl<T> blocks, and read trait bounds. You should also know that a + b calls the Add trait. A default type parameter lets a generic item pick a type for you when the caller doesn't name one.5 min readimpl blocks, know what a trait bound is, and understand ownership and references. It covers how to use a type parameter that no field stores, and why you would want to.5 min read