Loading tutorials
T: Display. It also assumes you know basic ownership and borrowing. Trait objects are not covered here. Thi5 min readfn f<T: Shape>(x: T). You should also know what Box and & references are. The chapter explains dyn Trait as a type: what it names, why the compiler tr5 min readdyn Trait value: &dyn, &mut dyn, Box<dyn>, Rc<dyn>, and Arc<dyn>. It assumes you know basic ownership and borrowing, how to implement a trait for a struct, and how Box and references work. The previous chapter showed that `dyn Trait4 min readBox and references, and have seen dyn Trait and Vec<Box<dyn Trait>>. Here you will look at what a trait object value is in memory and how a method call finds the right code at runtime.4 min readBox and references. It also assumes you know that dyn Trait is an unsized type that is used behind a pointer. Here we follow a single method call on a trait object from source code to machine-level beh5 min readBox and references. You should also know that a dyn Trait value is unsized and must sit behind a pointer. The previous chapters covered fat pointers, vtables and how a call is resolved at ru5 min readimpl Trait, or with dyn Trait. This chapter gives you criteria for choosing between them. It assumes you can define and implement traits, write trait bounds, and use Box and references. It also assumes you know that `dyn Trai5 min readBox<dyn Trait> is built and used, and that dyn Trait calls go through a vtable. It applies those ideas to closures, which is where most Rust programmers first need trait objects.6 min readBox<dyn Trait> and &dyn Trait are used, and what a vtable is. Here you learn the rules that decide whether dyn Trait is allowed for a given trait. You also learn how to read the compiler's complaints and fix them.5 min readBox<dyn Trait> and understand that dyn Trait is an unsized type. The previous chapter listed the rules that decide whether a trait is dyn compatible. This chapt5 min readdyn Trait is, how Box<dyn Trait> and &dyn Trait work, and the basics of lifetimes such as &'a str and struct S<'a>. Here you will see that every trait object type carries a hidden lifetime, how the compiler picks it, and how to override it when the defaul5 min readBox<dyn Trait> and &dyn Trait work. It also assumes you have used thread::spawn and Arc at a basic level. The question here is why a trait object is often not thread-safe by default, and how to say that it is.5 min readBox<dyn Trait> values, and that you know a trait object is a fat pointer made of a data pointer and a vtable pointer. Here you will see how a trait that requires another trait behaves as a trait object, and when you can convert a dyn Sub into 5 min readdyn Any is the standard way to do this. This chapter covers how Any works, three ways to use it, and the mistakes that cause trouble.6 min read