Loading tutorials
impl block. You should have seen generics like Vec<T> and used Box and references. Later chapters build on the trait basics reviewed here.2 min readBox and references. It covers what the type dyn Trait is and why it behaves differently from other types. Pointers to it and the vtable come in later chapters.2 min readBox and references work. It also assumes you have seen the dyn Trait type from the previous chapter.2 min readdyn Trait means and why trait objects must sit behind a pointer such as &dyn Trait or Box<dyn Trait>. Here we look at what that pointer contains and what the compiler builds so a method call can be resolved at runtime.3 min read&dyn Trait and Box<dyn Trait> written down. Here you will see what happens when a method is called through one of them.2 min readBox. It also assumes you know that dyn Trait is an unsized type that must sit behind a pointer.2 min readBox and references. It helps you choose among three ways to write code that works with many types.2 min readFn, FnMut and FnOnce closure traits, Box, and the basics of dyn Trait from earlier chapters.2 min readBox<dyn Trait> and know that method calls on it go through a vtable. Here you will learn which traits the compiler accepts behind dyn. This property is called dyn compatibility. Older material calls it object safety.2 min readSelf or have no receiver, cannot be used as dyn Trait. Here you will see how to keep such methods without giving up trait objects.2 min readBox<dyn Trait> and &dyn Trait work, and that you can read lifetime annotations such as 'a on functions and structs.2 min readBox<dyn Trait>, Arc, and thread::spawn. It also assumes you know what Send and Sync mean for ordinary types.2 min readBox<dyn Trait> values, and know what a vtable is. It covers how a trait that requires another trait behaves as a trait object, and how to convert between the two.2 min readBox<dyn Trait> works, what a supertrait is, and that dyn Trait hides the concrete type. Sometimes you need that type back, for example to read a field that is not part of the trait. std::any::Any lets you do that with a runtime check.2 min read