MCPcopy Index your code
hub / github.com/dtolnay/rust-quiz

github.com/dtolnay/rust-quiz @question37

Chat with this repo
repository ↗ · DeepWiki ↗ · release question37 ↗ · + Follow
149 symbols 239 edges 44 files 0 documented · 0%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Rust Quiz

What is the output of this Rust program?

https://dtolnay.github.io/rust-quiz

If you enjoy the Rust Quiz and also know C++, you may like to check out http://cppquiz.org which inspired this project.

Contributing

I welcome suggestions for new quiz questions, either by filing a GitHub issue in this repository or by sending a pull request containing your question, hint, answer, and explanation of the answer.

The best questions are drawn from personal experience writing or reading Rust code and being bewildered by its behavior.

Aim for no more than 25 lines including blank lines, but shorter than that is better. Questions up to 35 lines may be accepted if there is no possible way to frame the same idea more concisely. Aim for no wider than 40 columns. The only exceptions on width will be for obvious boilerplate that is not necessary to read for solving the question.

The website shows choices for "undefined behavior" and "does not compile", but please prefer adding questions that do compile and are well-defined.

  • Not fun: "does this program compile or does it not compile?"
  • Not fun: "is this undefined behavior or is it not?"
  • Fun: "does this print obvious possibility A or obvious possibility B?"

To add a question, you need to add one .rs file and one .md file under the questions/ directory. Pick a very brief (2-4 words) description to include in the file names. Please use 000 as the question number to avoid races between concurrent pull requests. I will assign a number when merging.

Refer to an existing .md file and copy the format. In particular, you will need to provide a correct answer on the first line, a difficulty rating (1, 2 or 3) on the second line, a Hint section, and an Explanation section.

The difficulty rating should primarily reflect how obscure is the knowledge required to confidently solve the question.

When writing a hint, keep it brief. Maximum three lines, maximum two sentences is ideal.

In the explanation, feel free to be as thorough as possible without dwelling on concepts that are not relevant to the crux of the quiz question.

To launch the site locally and preview your rendered Markdown, run the following inside this directory.

# Package all the questions into a single JavaScript file
# and serve website over http at localhost:8000.
cargo run -- serve

Then your question, assuming you numbered it 000, will be accessible at http\://localhost:8000/rust-quiz/0.

License

The quiz questions, explanations, website, and all other intellectual property in this repository are all licensed under the Creative Commons Attribution-ShareAlike 4.0 International License.

Extension points exported contracts — how you extend this code

Trait (Interface)
(no doc) [4 implementers]
questions/029-tuple-trailing-commas.rs
Trait (Interface)
(no doc) [2 implementers]
questions/021-closure-or-logical-or.rs
Trait (Interface)
(no doc) [2 implementers]
questions/014-trait-autoref.rs
Trait (Interface)
(no doc) [2 implementers]
questions/015-inference-of-number-type.rs
Or (Interface)
(no doc) [2 implementers]
questions/031-method-lookup.rs
Trait (Interface)
(no doc) [2 implementers]
questions/005-trait-resolution-hrtb.rs
Trait (Interface)
(no doc) [2 implementers]
questions/033-range-full-method.rs
Trait (Interface)
(no doc) [1 implementers]
questions/010-shadowed-trait-object-method.rs

Core symbols most depended-on inside this repo

hide
called by 15
docs/quiz.js
f
called by 11
questions/025-unit-infallible-match.rs
show
called by 11
docs/quiz.js
p
called by 7
questions/030-clone-pointers.rs
f
called by 6
questions/021-closure-or-logical-or.rs
f
called by 6
questions/031-method-lookup.rs
p
called by 4
questions/029-tuple-trailing-commas.rs
p
called by 3
questions/005-trait-resolution-hrtb.rs

Shape

Function 86
Method 27
Class 19
Interface 11
Enum 6

Languages

Rust86%
TypeScript14%

Modules by API surface

docs/quiz.js21 symbols
src/render.rs11 symbols
questions/027-subtrait-dispatch.rs8 symbols
src/serve.rs6 symbols
src/main.rs5 symbols
questions/025-unit-infallible-match.rs5 symbols
questions/023-inherent-vs-trait-method.rs5 symbols
questions/020-break-return-in-condition.rs5 symbols
questions/005-trait-resolution-hrtb.rs5 symbols
questions/031-method-lookup.rs4 symbols
questions/012-binding-drop-behavior.rs4 symbols
src/error.rs3 symbols

For agents

$ claude mcp add rust-quiz \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact