Code2Img

Rust code screenshots.

How to screenshot Rust code properly: what Rust snippets actually look like, how auto-detection behaves, the theme that reads best, and the settings that keep the card legible.

What people actually paste

Rust snippets are the most syntax-dense of the set: lifetimes (<'a, 'b: 'a>), trait bounds (T: Clone + Send + 'static), match arms, ? propagation, and attribute macros (#[derive(Debug, Serialize)]). Two features break naive highlighting. First, lifetimes and char literals share the apostrophe, so 'a and 'x' sit one character apart. Second, macros are called with a bang and their contents are not parsed as Rust, so println!("{}", x) and format!("{name}") look unlike anything else in the file.

How auto-detection behaves

Rust is rule 4, after Python, Ruby and Go. Four triggers: fn name(, let mut, the turbofish ::<, and println!(. That covers most real snippets. The gap is declaration-only code: #[derive(Debug)] plus struct Foo { … } plus impl Foo { … } contains none of the four, and a line starting with a brace is not present either, so the whole thing falls to the typescript default and gets TypeScript-flavoured colouring. let mut also appears in some pseudocode; if a snippet contains it but is not Rust, auto will still say Rust.

Theme that reads best

tokyo-night for dark cards: it gives lifetimes, macros and types three clearly separated hues, which is what a Rust snippet needs, and its background is dark enough that the many brackets do not shimmer. vitesse-light is the light counterpart — muted enough that a where-clause does not turn into confetti.

Three tips

Other languages

The same advice, for the languages people paste most.

How Code2Img compares

Feature by feature, against the other code screenshot tools.