High-performance cache policies and supporting data structures.
This style guide covers two related but distinct concerns:
src/. The audience is a Rust developer reading the API.docs/design/. The
audience is a contributor (or future maintainer) trying to
understand why a piece of cachekit looks the way it does.Both styles share the same goals: make behaviour, invariants, and trade-offs clear without verbosity, and keep examples compile-ready and focused.
Use //! and follow this order:
Use /// with a one-sentence summary. Mention invariants or complexity
only when they matter. Avoid Args/Returns sections unless behavior is
non-obvious.
//! ## Architecture
//! ...
//!
//! ## Key Components
//! ...
//!
//! ## Core Operations
//! ...
//!
//! ## Performance Trade-offs
//! ...
//!
//! ## When to Use
//! ...
//!
//! ## Example Usage
//! ```rust
//! // ...
//! ```
//!
//! ## Type Constraints
//! ...
//!
//! ## Thread Safety
//! ...
//!
//! ## Implementation Notes
//! ...
/// Brief summary of behavior.
Files in docs/design/ follow a shared shape so a reader who has
finished one knows what to expect from the next. The shape is not a
strict template — sections are added or omitted as the topic
warrants — but the meta-conventions below are uniform.
Every design doc opens with a blockquote that names what the doc
covers and links its immediate siblings. The convention is
> Status: <one-sentence framing>. Companion to <links>.
> Status: design rationale for the concurrent surface that ships today
> behind the `concurrency` feature flag. Companion to the cross-cutting
> principles in [`docs/design/design.md`](/cachekit/design/design.html) §3 and the trait
> rationale in [`docs/design/trait-hierarchy.md`](/cachekit/design/trait-hierarchy.html).
The preamble does three things in one paragraph:
§1, §2, …) are encouraged when other
docs may want to cross-reference specific sections. design.md,
ttl.md, and trait-hierarchy.md all do this.When two or more options have different trade-offs, use a table rather than a bulleted list. Tables make it easy to scan one column for one property and force the writer to give every option the same set of properties.
| Property | Option A | Option B |
|----------|----------|----------|
| Cost | … | … |
| Memory | … | … |
Use fenced code blocks tagged text for ASCII diagrams. Avoid Mermaid
or other rich diagram formats — plain text renders in every tool
(rustdoc, GitHub, terminal less) without configuration. See the
hierarchy diagram in trait-hierarchy.md for the conventional shape.
┌──────────────────┐
│ Cache<K, V> │
└────────┬─────────┘
│ extends
┌────────────┼────────────┐
▼ ▼ ▼
Capability1 Capability2 Capability3
Every concrete claim that names a type, trait, or method should link
the source file. Use relative paths
([src/policy/lru.rs](../../src/policy/lru.rs)) so the docs work
both on GitHub and in local clones. When citing a specific feature
gate, name the feature inline (gated by #[cfg(feature = “ttl”)]`).
[concurrency](/cachekit/design/concurrency.html) rather than [Concurrency design](...).
This survives renames better and matches the rest of the corpus.[design.md §3](/cachekit/design/design.html), [concurrency.md §"Failure modes"](/cachekit/design/concurrency.html#failure-modes).See Also closerEvery design doc ends with a ## See Also section. The conventional
order is:
The framing matters: a bare list of links is less useful than a list where each entry says why the reader might follow it.
Checklist:
See Also block to siblings that should know about the
new doc, and add a corresponding bullet to
docs/index.md.design.md’s See Also block so the new doc is
reachable from the index design overview.When not to use X (or the equivalent) — explicit
boundaries are part of the contract.