expression

Full jitter: choose a delay within a cap

Full jitter spreads scheduled attempts by selecting a uniform random delay between zero and a computed ceiling. Here predetermined valid draws stand in for an injected sampler. They are not a random-number generator and do not establish a distribution. Expected stdout (not executed): Some(0) Some(47) Some(100) None Common mistake: Using a constant draw in production or assuming jitter guarantees no simultaneous retries.

Formal Syntax & Structure

rust syntaxrust
sample from 0..=backoff_cap

Working Example

Example Snippetrust
fn main() {    fn valid_draw(cap: u64, draw: u64) -> Option<u64> {        (draw <= cap).then_some(draw)    }    for draw in [0, 47, 100, 101] {        println!("{:?}", valid_draw(100, draw));    }}
Rust Reference