Loading tutorials
impl blocks, and that you know how to implement a trait. You should also be comfortable with generics and trait bounds, with ownership and the Copy trait, and with associated types. Later chapters build on each of these.2 min readimpl blocks, how to implement a trait, basic generics, and the Copy trait. You should also know what an associated type is. We implement Add for a small vector type and look at what the compiler does with a + b.2 min readAdd implementation from the previous chapter. It covers the Output type that every binary operator trait declares and how to choose it.2 min readCopy trait, and the basic impl Add for T pattern from the previous chapters.2 min readimpl Add for a struct, you know what the Output associated type does, and you understand why Copy matters when operands are passed by value.2 min readAdd and the Output type.2 min readAdd for a struct, what the Output associated type is, and how Copy affects operands that are passed by value.2 min readAdd for a type, how the Output associated type works, and why operators take their operands by value.2 min read& and &mut borrows. It also assumes you have read the earlier chapters on Add and Output.2 min readAdd impl from earlier chapters, and understand borrowing. Comparison operators follow the same "operator is a method call" idea, with two differences. They live in std::cmp, not std::ops. They also take their operands by ref2 min readCopy trait. You should also have seen how Add and Mul are implemented for a user type.2 min readimpl Trait for Type blocks and have seen Add, Mul and the Rhs parameter in earlier chapters. It explains which operator impls the compiler accepts and which it rejects.3 min readAdd for a struct, how Output works, and how Copy affects operands. The bitwise and shift operators follow the same pattern. Only the trait names change.2 min readAdd, Output, and reference impls. You should also know the basics of declarative macros: a macro_rules! definition is a set of patterns, each paired with code to generate.2 min readAdd, know what Output and Rhs do, and have seen AddAssign, PartialOrd, and the orphan rule. Those chapters covered how to overload. This one covers whether you should.2 min read