$ show dtolnay/rust-quiz
Rust Quiz is a monolith application that hosts a collection of medium-to-hard Rust quiz questions. The core function is to parse Markdown question files and corresponding Rust source files, compile and execute the Rust code to verify correct answers, and generate a JavaScript bundle for a static website. It uses a parallel worker pool (rayon) for efficient validation and includes a local HTTP server based on hyper for development. The codebase is well-structured with clean error handling (thiserror) and modern Rust practices. While the primary value is the question content, the build tooling is a robust example of a Rust code snippet tester with output validation and warning checking.
The LLM identified 2 files worth highlighting for reuse:
The core engine for processing quiz questions: reads .rs and .md files, parses answers/difficulty/hints/explanation using a carefully crafted regex, compiles each .rs file with rustc, runs the binary, and verifies the output matches the expected answer. It also checks that expected compiler warnings are present. This component demonstrates a robust pattern for automated validation of Rust code snippets, though it is tightly coupled to the project's directory structure and error types.
A well-organized error enum using thiserror that covers all possible failure modes of the application: compilation errors, wrong output, unexpected warnings, etc. Includes a custom `CommaSep` display helper for warnings. This is a clean example of idiomatic Rust error handling that could serve as a template for other applications.