Loading tutorials
Vec, String and Box, are comfortable with iterators and closures, and can run cargo build, cargo test and cargo bench. It also assumes you know the stack and heap split from the previous chapter.6 min readVec, String and Box, and with iterators and closures. It also assumes you can run cargo run and cargo test. The previous chapters covered where allocations come from and how to count them. This one trains your eye 5 min read&, &mut and a named lifetime. Earlier chapters showed how to count allocations and spot clone, to_string and collect. This chapter fixes the most common source of those 5 min readString, &str and Vec. It also assumes you have seen the earlier chapters on hidden allocations and on borrowing in APIs.4 min readVec and String own heap memory, and that you can run cargo run and read the output of a small benchmark. You should also have seen the counting allocator from the measurement chapter. Here you will learn how a growable collection chooses its size, how to tell 6 min readString and Vec, and have read the earlier chapters on stack and heap storage and on measuring allocations. It covers one technique: keeping a single buffer alive across loop iterations so the loop stops allocating once the buffer has6 min readVec, String, and basic iterator adapters such as map and filter. It also assumes you have seen the counting allocator from the measuring chapter. You will learn to spot collect() calls that only exist t5 min readVec grows and when it allocates. It also assumes you can measure allocation counts, as covered earlier in this tutorial. You should be comfortable with generics, const-sized arrays, and adding a crate to Cargo.toml.6 min readVec, String and Box, traits and generics, and how to run cargo build and cargo bench. It also assumes you can count allocations with the counting allocator from the measurement chapter.5 min readString and Vec, and how Rc and Arc count references. The earlier chapters showed how to avoid allocating at all. Here the data has to live on the heap, and the question is how to store it with less memory and fewer copie6 min readVec/String/Box basics, and how to measure allocations with the counting allocator from earlier in this tutorial. It also assumes you can add a crate to Cargo.toml.6 min read&str versus String, and the Cow type from the earlier chapter on clone-on-write. It also assumes you can run cargo test.4 min read#[global_allocator] works from the chapter on measuring allocations. It also assumes you can run cargo build --release and compare two builds with a benchmark. Earlier chapters removed allocations from your code. This chapter covers the opposite option: keep the5 min read