Loading tutorials
cargo run. You should know how to declare variables and define fn main. You do not need to know traits yet. Later chapters cover them when you implement your own output.2 min readmain function, declare variables, and run a program with cargo run. It also assumes you know that a trait is a set of behavior a type can implement.2 min readmain function, run it with cargo run, and know that println! takes a format string with {} placeholders. Here you will learn the three ways a placeholder can find its value.2 min read{} placeholders work in println! and format!. It covers how to print the brace characters themselves.1 min read{} placeholder from the previous chapters.2 min readprintln! placeholders work, and what a trait is. Deriving Debug for your own types comes in the next chapter.2 min read{} and Display. Here you will learn how #[derive(Debug)] gives your own types {:?} output.2 min readDebug on a struct or enum and print it with {:?}. It builds on that.2 min read{} is a placeholder in println!, and have seen {:?} for Debug output. It covers the part of a placeholder after the colon that controls how wide the output is and where the value sits inside that width.2 min read{}, and that width and alignment look like {:>8}. Here you add three more controls: precision, the sign flag, and zero padding.2 min read{} and {:8}, and that you can run a program with cargo run. Here you will learn the type characters that change how a number is written: x, X, b, o, e, and E. You will also learn the # flag.2 min read{:8}, {:<8}, and {:.2} from the earlier chapters. Here you will supply the width and precision as values instead of typing them into the format string.2 min readprintln! placeholders, the Display and Debug traits, and the basics of Result. Every macro below uses the same format-string syntax you have already seen. They differ in where the text goes.2 min readprintln! placeholders work. Here you will make {} work with your own types.2 min readimpl fmt::Display for a type and know that {:>8} sets width and alignment. If not, review the chapters on width and on implementing Display first.2 min readDebug with #[derive(Debug)], you know what a trait is, and you have already implemented Display for a type. Here you will write Debug by hand and learn when that is worth doing.2 min readprintln!, the Debug trait, and #[derive(Debug)] from earlier chapters. It also assumes you know basic ownership and moves.2 min readprintln!, {} and {:?}, and that a type needs a trait implementation (Display or Debug) before it can be printed.2 min read