Project 10: Capstone — Design Your Own Safe Abstraction

Your choice! Design a library with a safe public API that uses unsafe internally. Examples: a custom allocator, a parser combinator library, a zero-copy serialization library, or a novel data structure.

Quick Reference

Attribute Value
Primary Language Rust
Alternative Languages None
Difficulty Level 5: Master
Time Estimate 1-3 months
Knowledge Area Full Rust Mastery
Tooling Your choice
Prerequisites All previous projects

What You Will Build

Your choice! Design a library with a safe public API that uses unsafe internally. Examples: a custom allocator, a parser combinator library, a zero-copy serialization library, or a novel data structure.

Why It Matters

This project builds core skills that appear repeatedly in real-world systems and tooling.

Core Challenges

  • Choosing the right ownership model → maps to deep design thinking
  • Encapsulating unsafe correctly → maps to upholding invariants
  • Designing ergonomic lifetimes → maps to API usability
  • Documenting safety invariants → maps to communication and correctness

Key Concepts

  • Everything from Projects 1-9
  • Rust API Guidelines: https://rust-lang.github.io/api-guidelines/
  • Unsafe Code Guidelines: WG-unsafe-code-guidelines repository
  • Open Source Examples: Study high-quality Rust crates (serde, tokio, rayon)

Real-World Outcome

Deliver a working demo with observable output that proves the feature is correct.


Implementation Guide

  1. Reproduce the simplest happy-path scenario.
  2. Build the smallest working version of the core feature.
  3. Add input validation and error handling.
  4. Add instrumentation/logging to confirm behavior.
  5. Refactor into clean modules with tests.

Milestones

  • Milestone 1: Minimal working program that runs end-to-end.
  • Milestone 2: Correct outputs for typical inputs.
  • Milestone 3: Robust handling of edge cases.
  • Milestone 4: Clean structure and documented usage.

Validation Checklist

  • Output matches the real-world outcome example
  • Handles invalid inputs safely
  • Provides clear errors and exit codes
  • Repeatable results across runs

References

  • Main guide: RUST_BORROW_CHECKER_LIFETIME_PHILOSOPHY.md
  • All previous knowledge