FFORGE//RS
← Roadmap

rust / LEVEL 4

The retry loop with no budget

EST.40 MIN
01

THEORY / RETRIEVAL

What to restore

  • Build a generic async retry loop over Future-producing operations
  • Distinguish future cancellation from rollback of completed side effects

An async function is a state machine

Calling an async function creates a future; work advances only while that future is polled. Dropping it stops future polling, but side effects completed before the last suspension point remain completed.

Retry counts are part of the API

A retry helper must define whether the number means total attempts or retries after the first call. Using `NonZeroUsize` makes an impossible zero-attempt result unrepresentable when no error value exists yet.

CHECKPOINT

What happens when a caller drops a future while it is waiting between two retry attempts?

ISOLATED RUST 1.96
src/lib.rsEDIT

02 / IMPLEMENTATION

Implement the contract

Implement `retry` so `attempts` means total calls, success returns immediately, and the final error is returned after the exact budget. Do not require Clone on errors.

Initializing editor…
CLOUD SANDBOXnetwork off · 256 MB · 12 s
1 / 64 KB
OUTPUT
Runner is waiting for a submission.