Spec contract tests for a Rust token bucket
Your task
You wrote a token bucket rate limiter in Rust. Each key has a bucket of capacity tokens that refills at refill_per_sec, and allow(key) spends 1 token or returns false. An agent will write its test suite.
Write the prompt you would give the agent for the tests.
What you know:
- the public API is
Limiter::new(capacity: u32, refill_per_sec: f64)andallow(&self, key: &str) -> bool - inside, it reads the time with
Instant::now() - buckets start full, and many threads call
allowat once - you can add dev-dependencies
Then, in a few sentences: what does a vague prompt get most wrong here?