ProCore

Rust Standard Library

The parts of std that people reimplement by hand: the String and &str split, chars against bytes, the split and trim families, parse and the turbofish, the lazy iterator adaptors, collect into anything that implements FromIterator, the Option and Result combinators, the three sorts, and the Display against Debug distinction. Ten corners where a built-in already does the job and one behaviour in each is not what you assumed.

Questions90
Topics10
Answering time68 minutes
At five a day18 days
LevelCore

Who it is for

Reaches for a dependency before the built-in.

The behaviour people get wrong after they are already productive in the language.

You will get the most out of it if you have written Rust recently enough to read it without effort, and have been surprised by it at least once. If you are picking the language up for the first time, start with Rust Essentials and come back to this one.

How long it takes

90 graded questions at roughly 45 seconds each is about 68 minutes of answering in total.

At the default five questions a day, and because the session mixes in your other courses, expect around 18 days — call it 3 weeks — to see everything once, plus a few weeks of thinning reviews after that before it is all mastered.

A question is mastered on the third correct answer, once the gap between reviews has grown past a week — so a course cannot be finished in a weekend however long you sit with it.

Question mix

  • 60 multiple choice
  • 10 concept cards
  • 10 predict the output
  • 10 put it in order
  • 10 matching questions

Syllabus

What you will be asked about

  1. 01

    &str, String and Who Allocates

    Choose between &str and String by what each one owns, and name which calls allocate.

  2. 02

    chars(), bytes() and Why You Cannot Index

    Explain what len() counts, and pick chars(), bytes() or char_indices() for the job at hand.

  3. 03

    split and the Empty Segments

    Predict how many pieces a split produces, including the empty ones, and pick splitn, split_once or split_whitespace when they fit better.

  4. 04

    trim, strip_prefix and Friends

    Distinguish trimming a set of characters from stripping one occurrence of a pattern, and say what each one returns.

  5. 05

    parse, FromStr and the Turbofish

    Use parse with an explicit target type, and handle the Result it returns instead of unwrapping it.

  6. 06

    Adaptors Are Lazy

    Say when an iterator chain actually runs, and predict what map, filter, zip, enumerate, take_while, fold and flat_map yield.

  7. 07

    collect Into Anything

    Steer collect to the container you want, and name the cases where it changes the shape of the result rather than just the type.

  8. 08

    Combinators, Not match

    Replace a match on Option or Result with the combinator that says the same thing, and predict when the fallback is evaluated.

  9. 09

    sort, sort_by_key, sort_unstable

    Pick the right sort for the data in hand, and explain what sorting returns, what it does to equal elements, and why floats will not sort.

  10. 10

    {} Against {:?}

    Choose between Display and Debug for a value, and predict how each renders strings, chars, floats and containers.

8 more topics, and all 90 questions

Rust Standard Library is a Pro course. One subscription opens it and every other course in the catalogue, including the ones still being written.

See pricing Find a free course

A question from this course

&str, String and Who Allocates

What does this print?

fn main() {
    let s = "hi";
    let t = s.to_uppercase();
    println!("{} {}", s, t);
}
  • Ahi HI
  • BHI HI
  • CHI hi
  • DIt does not compile: s is not declared mut
Show the answer

A hi HI

You may have expected s to change because the method reads like a command; to_uppercase cannot mutate anything, since s is a view into a literal that lives in read-only memory. It returns a brand new String and leaves the original untouched. Nothing needs mut here precisely because nothing is written.

The rest of the track

Rust at every depth

FreeFoundation

Rust Essentials

The model underneath the syntax. Assigning a String to a second name moves it and the first name stops working, while an i32 is simply copied; borrowing, Option and exhaustive match are the same compiler insisting you say what happens in every case.

90 questions · 68 minutes

ProCore

Rust Core

The compiler's side of the argument, made explicit. A lifetime constrains how long a borrow may be used rather than naming a span of time, an iterator chain does nothing at all until something consumes it, and a trait bound is the only thing a generic function is allowed to assume.

90 questions · 68 minutes

ProCore

Rust Data & Collections

The containers people reach for daily and the places they bite: indexing that panics where get() hands back None, a borrow that freezes the Vec it came from, and an entry() call that writes when you only meant to read. Every snippet here runs, so the answers are what rustc really printed.

90 questions · 68 minutes

ProCoreInterview prep

Rust Errors & Edge Cases

Failure as a value rather than an exception: Option where there is nothing to say and Result where there is, the ? operator and the From impl it quietly needs, custom error enums, Display against Debug, and the line between an error a caller can act on and a panic that ends the process. Every snippet here either runs or refuses to compile for a reason you can name.

90 questions · 68 minutes

ProAdvanced

Rust Idioms & Pitfalls

Ten habits that compile and still mark the code as written by someone thinking in another language: the clone that silences the borrow checker, unwrap as punctuation, String parameters where a slice would do, index loops, a collect nobody reads, a five-line match that is one combinator, &Vec in a signature, lifetimes elision would have written, inherent methods that want to be trait impls, and drop misread. Each one is shown working, then shown costing something.

90 questions · 68 minutes

ProAdvancedInterview prep

Rust Advanced

The type system and the borrow checker in earnest: elision that quietly ties a return to &self, two &mut borrows that look disjoint and are not, RefCell panicking at run time where the compiler would have refused. Every snippet here either compiles or fails to for a reason you can name.

90 questions · 68 minutes

ProAdvancedInterview prep

Rust Performance

What a Rust program actually costs, read off the things you can observe: Vec::capacity, strong_count, size_of and the order drops run in. Every claim here is one the snippet proves, which is why none of them is a timing.

90 questions · 68 minutes

ProCore

Rust Testing

What a Rust assertion actually claims, and where that claim is weaker than it looks. assert_eq! and its argument order, should_panic and its substring match, tests that return Result, cfg(test) modules against integration tests, doc tests, floats, and the difference between a failed assertion and a panic somewhere else.

90 questions · 68 minutes

ProAdvancedInterview prep

Rust Interview Questions

The questions a Rust interview actually turns on: where a value's owner is at each line, why two borrows that look disjoint are not, and what a lifetime annotation promises and what it cannot. Ownership and moves, aliasing, lifetimes, String against &str, Vec against slices, Option and Result, traits and dispatch, monomorphisation, Rc and RefCell, and what makes a type safe to send between threads.

90 questions · 68 minutes

Start Rust Standard Library
in tomorrow’s session.

Enrol and this course joins your daily five, mixed in with everything else you are studying — 90 questions spread over about 18 days rather than dropped on you at once.

Browse the catalogue