Rust Quiz asks what this program prints, then explains why
Medium to hard Rust questions with explanations
At a glance
- What is it?
- rust-quiz is a set of Rust questions with worked explanations, published as a static site where each page asks for the output of a short program. Contributing is unusually constrained: under 25 lines, under 40 columns, and questions about compile failures are explicitly discouraged.
- Who is it for?
- Read Rust Quiz if you want a working test of Rust semantics rather than a reference manual, and submit a question if you have one that puzzled you in real code. The site is useful for interview preparation and for catching habits carried over from C++.
- Can I use it commercially?
- Yes, with credit. CC-BY-SA-4.0 allows commercial use as long as you credit the authors and indicate what you changed. It is written for creative content, so check how it applies to any code.
- Is it still maintained?
- Yes. The repository last received commits 17 days ago.
- What is it written in?
- Mainly Rust, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on November 7, 2026, and from our analysis. They are not legal advice.
Star history
- dtolnay/rust-quiz1,924 ★ · +0
| Repository | 2026-10-16 | 2026-11-07 |
|---|---|---|
| dtolnay/rust-quiz | 1.9k | 1.9k |
0 Stars in the last 22 days, measured from the daily GitHub snapshot. Compare with other projects
Editorial analysis
Every page is one question and one output
The whole format fits on a screen: a heading asking what the output of a Rust program is, a short listing, and multiple choice answers. The published site lives at dtolnay.github.io/rust-quiz, and the README's entire pitch is that single question.
The contributing guide prefers questions that compile and are well-defined, rather than questions about compilation or undefined behaviour; it frames a fun question as choosing between obvious outputs A and B. That constraint comes straight from the contributing guide, which lists what is not fun: asking whether a program compiles, or whether behaviour is undefined. Fun, in this project's terms, is whether the program prints obvious possibility A or obvious possibility B.
The result is a quiz you can answer without touching a compiler, which is what makes it usable on a phone or during a screening call, and also what makes it different from a test suite. Nothing here verifies your answer against a real compiler, so a question written years ago can drift from current behaviour.
The house style is narrow on purpose
The contributing guide is the most detailed document in the repository, and it reads as a style guide rather than a legal document.
Questions should be no more than 25 lines including blank lines, with shorter preferred. Up to 35 lines may be accepted only when there is no way to frame the same idea more concisely. Width is capped at 40 columns, with the only exception being boilerplate that is not necessary to read in order to solve the question.
The stated source of good questions is personal experience, writing or reading Rust code and being bewildered by its behaviour. That origin story matters for judging the catalogue: these are the questions that surprised one experienced Rust programmer, which biases the set toward the parts of the language where the rules are subtle rather than the parts everyone learns in the first week.
The README also points at cppquiz.org as the inspiration for the project, for readers who know C++.
Each question is a .rs file plus a .md file
Adding a question means adding exactly two files under the questions/ directory, a Rust file and a Markdown file. Naming uses a brief two to four word description, and the number in the filename must be 000 to avoid collisions between concurrent pull requests; the maintainer assigns the real number when merging.
The Markdown file has a required structure, and the guide says to copy an existing one. The first line is the correct answer, the second line is a difficulty rating of 1, 2 or 3, and there must be a Hint section and an Explanation section. The rating is meant to reflect how obscure the required knowledge is rather than how hard the code looks.
Hints have their own limit: a maximum of three lines, with two sentences considered ideal. Explanations have the opposite instruction, be as thorough as possible, but without dwelling on concepts irrelevant to the crux. That asymmetry is deliberate and produces the site's best reading experience, since the hint has to be short enough not to give the answer away and the explanation has to answer the follow-up question properly.
Previewing locally packages the questions into one file
To see a question rendered before opening a pull request, you run the site locally from the repository root:
cargo run -- serveThat packages all the questions into a single JavaScript file and serves the site over HTTP on port 8000. A question you numbered 000 is then reachable at http://localhost:8000/rust-quiz/0.
The build is a real Rust binary rather than a static site generator script. Cargo.toml names the package rust-quiz at version 0.0.6, edition 2021, with publish = false and an exclude entry for the rust-quiz binary, so it is a tool for the site rather than a library anyone depends on.
The dependency list explains the architecture: hyper and hyper-util with http1, http2 and server features, hyper-staticfile for serving assets, pulldown-cmark for Markdown rendering, tokio with the full feature set, rayon for parallel work, oqueue as a queue, clap for the CLI, serde and serde_json for the packaged question data, and thiserror plus remain for error handling. num_cpus is there for sizing the parallelism.
A JavaScript linter in a Rust repository
The repository root has a package.json, and it is not part of the site build:
{
"devDependencies": {
"@eslint/js": "^9.19.0",
"eslint": "^9.19.0",
"globals": "^15.14.0"
}
}Other root entries include.gitlab-ci.yml alongside.github/, so there is CI configuration for two forges, plus a.cargo/ directory, docs/, src/ and the rust-quiz binary.
Licence, cadence and the limits of a quiz
Everything in the repository, questions, explanations, website and other intellectual property, is licensed under the Creative Commons Attribution-ShareAlike 4.0 International License. That is unusual for a code project, though Cargo.toml also sets the same identifier as the package license.
The practical consequence for reuse is that you may copy and adapt the questions with attribution provided, and that adaptations must be shared under the same licence. Fine for study material, worth knowing before you build an internal quiz from it.
Cadence has slowed. Releases are named after questions rather than versions, and the three most recent are question35 and question36 both dated 2022-09-26, then question37 on 2025-01-25. The last push was on 2026-07-30, so the repository is not abandoned, but new questions are rare.
Two limits follow from all this. A question is written against the Rust of its moment, so behaviour around newer language features may not be what the answer says. And a quiz verifies reasoning, not code: nothing here will tell you whether your compiler agrees.
Editorial conclusion
Read Rust Quiz if you want a working test of Rust semantics rather than a reference manual, and submit a question if you have one that puzzled you in real code. The site is useful for interview preparation and for catching habits carried over from C++. Verify first that the question you are looking at matches your compiler version, since the repository has not added a question since 2025-01-25.
Frequently asked questions
What is dtolnay/rust-quiz?
It is a set of medium to hard Rust questions, each showing a short program and asking what it prints, with a hint and a full explanation. The questions are published as a static site at dtolnay.github.io/rust-quiz.
How do I add a new question to Rust Quiz?
Add one .rs file and one .md file under the questions/ directory, with 000 as the question number to avoid merge races and a two to four word description in the filename. The Markdown needs the correct answer on the first line, a difficulty rating of 1, 2 or 3 on the second, plus Hint and Explanation sections.
Can I preview my question before submitting it?
Run cargo run -- serve in the repository root. That packages the questions into a single JavaScript file and serves the site on port 8000, where a question numbered 000 is at http://localhost:8000/rust-quiz/0.
What licence does Rust Quiz use?
The questions, explanations, website and other intellectual property are licensed under the Creative Commons Attribution-ShareAlike 4.0 International License, so reuse with attribution requires that adaptations share the same licence.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/dtolnay-rust-quiz)Star history chart for your README
[](https://hysenlabs.com/projects/dtolnay-rust-quiz)Was this useful?