Sitemap

Member-only story

Rust Gets Smarter: Automatically Tests Documentation Across All Build Targets!

4 min readAug 23, 2025

--

Press enter or click to view image in full size

I’ll admit something embarrassing: for years, my documentation was a lie.
My README examples looked polished, my code snippets were formatted perfectly, but if you actually copied and pasted them, half of them didn’t compile.

And I wasn’t alone. Most devs quietly accept that docs drift from reality.
“Sure, the example compiles in debug mode, but does it still work with --release? With that optional feature? On Windows vs Linux?”

That used to be wishful thinking.

But Rust just got smarter — it now tests your documentation across all build targets, making sure that your examples stay truthful in every context you claim to support.

It feels like the compiler whispering:

“I won’t let you lie to your users anymore.”

And honestly? That’s a blessing.

The Problem: Docs That Rot

Here’s a real example from one of my older crates:

/// Adds two numbers together.
///
/// ```rust
/// let sum = my_crate::add(2, 3);
/// assert_eq!(sum, 5);
/// ```
pub fn add(a: i32, b: i32) -> i32 {
a + b
}

--

--

SyntaxSavage
SyntaxSavage

Written by SyntaxSavage

Senior dev & team lead with 4+ years of shipping code at scale. Writes hot takes, clean hacks, and raw truths from the trenches.