Loading tutorials
if can appear on the right side of a let, and why one stray semicolon can break a function that looks correct. This chapter assumes you can build and run a program5 min readlet and let mut. You should also know the difference between a statement and an expression from6 min readif and else in Rust. It assumes you can build and run a program with cargo, know the primitive types (integers, booleans, strings), and understand let and let mut. It builds on the previous chapter's distinction between statements and expressions.6 min readloop and while. It assumes you can build and run a program with cargo, know the primitive types, and understand let and let mut. The for loop, loop labels, and break with a value get their own chapters. Here we focus o5 min readfor loops work in Rust, how ranges are built, and the common mistakes people make when iterating. It assumes you can build and run a program with cargo, know the primitive types, and understand let and let mut. You should also have read the chapters on loop and `while6 min readbreak with a value, and loop labels. It assumes you can build and run a program with cargo, know the primitive types, and understand let and let mut. It also assumes you have read the earlier chapters on if/else, loop, while, and for.7 min readmatch compares a value against a list of patterns and runs the code for the first pattern that fits. It is Rust's main tool for multi-way branching. It is also an expression, so it produces a value, and the compiler checks that you have handled every possible input.5 min readif let, while let, and let-else. They let you match one pattern without writing a full match. I assume you know match, Option, Result, let mut, and how to run a program with cargo.5 min readlet versus let mut. It also assumes you know that String owns heap data while &str is a view into string data. The chapter covers how to let a function use a value without taking it, and how to ch5 min readmatch, and you know that Option and Result are enums. You do not need to have written your own error types yet. By the end you will know how return and ? leave a function early, what ? expands 4 min readif/else expressions, and run programs with cargo. It covers how to structure a recursive function, what happens on the ca5 min readlet and let mut, and that you have met ownership and borrowing in outline. By the end you should be able to accept a closure or a function as an argument, pick the right trait 7 min readif/else and match as expressions, and use loop, break, continue, and return. It covers !, the never type, which describes expressions that never produce a value. It explains why panic!() can sit in a branch 5 min read