VoiceGem

How to dictate a Rust test attribute and assertion

Rust's test attribute and its assertion macro both dictate perfectly, needing no cleanup pass at all. Saying “hash open bracket test close bracket” returns #[test] with no spaces, and “assert underscore eq bang open paren left comma right close paren semicolon” returns assert_eq!(left, right); exactly as written.

A fourteen-word Rust test header is about 16 seconds of typing against about 5.1 seconds of speech. (sources: Dhakal, Feit, Kristensson & Oulasvirta, “Observations on Typing from 136 Million Keystrokes”, CHI 2018, 168,000 participants, 136 million keystrokes; Yuan, Liberman & Cieri, “Towards an Integrated Understanding of Speaking Rate in Conversation”, Interspeech 2006, 2,438 American English telephone conversations (Switchboard corpus). The speech figure is conversational rate, not a measured dictation rate — no such measurement exists.)

What lands in your editor
#[test]
fn parses_an_empty_input() {

This tool runs entirely in your browser. Nothing you type is sent anywhere, stored, or logged.

Step by step

  1. 1

    Say the attribute as three phrases

    Speak “hash open bracket test close bracket”. The hash binds rightward and both brackets bind tightly, so the attribute arrives closed up.

  2. 2

    Break the line

    Say “new line” before the function. VoiceGem resolves whitespace commands in the same pass, so the attribute and the definition are one utterance.

  3. 3

    Name the test with a casing command

    Say “fn snake case” then the behaviour. Rust test names are snake_case sentences and the run consumes every word until the open paren.

  4. 4

    Say the assertion macro

    Speak “assert underscore eq bang”. The underscore binds both sides and the exclamation mark binds both sides, so the macro name arrives intact.

Rust attributes are one of the few constructs that dictate with zero artifacts

Three characters have to bind correctly for #[test] to work, and all three do. The hash is one of only three right-attaching entries in VoiceGem's table, the open bracket attaches on both sides, and the closing bracket attaches left — so the attribute closes up without a single space.

The assertion macro is equally clean for a different reason: the underscore and the exclamation mark both attach on both sides, which are two of the ten both-sides entries. Neither construct was designed for; the flags were set per character and Rust happens to sit on the right side of all five.

Where the manual way breaks

Rust IDEs generate a test skeleton and typing #[test] is six keystrokes. Nothing here beats that for a single attribute.

Test modules with many long-named cases are where speaking pays. A dozen tests each with a six-word snake_case name is sixty underscores, and each one is a Shift-hyphen in the middle of a word. Dictating the module in VoiceGem is one casing command per test and the sentences you would have written anyway.

Doing this somewhere else? speech-to-code converter, in one place, what changes for dictating Rust doc comments, dictating Rust functions specifically, or the same thing for naming things in Rust by voice.

Common questions

No. In VoiceGem's table the hash binds rightward and both brackets bind tightly, so the attribute arrives closed up with no spaces at all.

Yes. Say “assert underscore eq bang”. Both the underscore and the exclamation mark attach on both sides, so the macro name stays intact.

Say “hash open bracket cfg open paren test close paren close bracket new line mod tests open brace”. Every character binds correctly.

Dictate an attribute, a test name and an assertion in one breath.

Open the tool