Loading tutorials
impl Trait for Type works. It also assumes you can read basic struct and enum definitions. By the end you will know what #[derive(...)] generates, what it requires of your types, and when to write the implementation yourself.5 min readDebug trait: what it promises, how #[derive(Debug)] satisfies it, where it is used in everyday Rust, and how it can fail to compile or leak data. It assumes you can read basic structs, enums, and generics, and that you know println! format strings.4 min read#[derive(Debug)] works and can read format strings like {} and {:?}. Here you will learn what the two Debug layouts look like, how the formatter flags change them, and where they can surprise you.4 min read#[derive(Debug)] works and how {:?} and {:#?} print values. It also assumes you can write impl Trait for Type. Derive covers most types. Sometimes its output is wrong for your type, and then you implement Debug yourself.4 min readimpl Trait for Type works, how println! format strings behave, and how Result is used. It builds on the previous chapter, where Debug gave you developer-facing output.4 min readimpl Trait for Type, use println! format strings, and have read the previous chapter on implementing Display. It explains why a type that implements Display also gets a to_string() method, and where that method behaves differently from what you might expe4 min readimpl fmt::Display for T with write!. It also assumes you know the basic format spec syntax, such as {:>8} and {:.2}. You will learn why those specs are sometimes silently ignored for your own types, and how to honor them.4 min readimpl Trait for Type works, how Result and ? behave at a basic level, and the difference between {} and {:?} in format strings. You have already seen Display on ordinary types. Here you apply it to errors, where the text is shown to people who did not wri3 min readimpl Trait for Type, and the basics of ownership. It also assumes you have used String::from("text") at least once. Here you will see what that call does and how to add the same kind of conversion to your own types.5 min readimpl Trait for Type, generics with trait bounds, and the From trait from the previous chapter. Here you will see how Into relates to From, when to use each, and how to take impl Into<T> as a parameter.4 min read? operator uses the From trait to convert errors as they propagate. It assumes you know basic Rust syntax, Result and Option, how impl Trait for Type works, and the From and Into basics from the previous chapters.4 min readFrom and Into from the previous chapters, how impl Trait for Type works, and how Result and the ? operator behave. It also assumes you can write a small error type with Display.4 min readimpl Trait for Type, and read Option and Result. It covers how Default is defined, how to implement it by hand, where the standard library calls it, and which mistakes to avoid. The next chapters cover deriving `Def4 min read#[derive(...)] works, what the Default trait is, and basic struct and enum syntax. It covers what #[derive(Default)] generates, how to pick the default variant of an enum, and where derive stops being the right tool.4 min readDefault, how struct literals work, and the basics of moves and Copy types. Here you will learn the struct update syntax, how it combines with Default, and the ownership and visibility rules that cause surprises.4 min readDebug, Display, From/Into, TryFrom, and Default. It also assumes Rust edition 2021, where TryFrom and TryInto are in the prelude. Here you will decide which trait fits a job and see all of them working in one small program.4 min read