expression

Measure elapsed ticks across counter wrap

A free-running u32 timer wraps after its maximum value. Wrapping subtraction yields the elapsed tick count modulo 2^32. It is an actual elapsed duration only when fewer than 2^32 ticks have elapsed; software must observe the counter often enough. This model does not read hardware or establish a real-time deadline guarantee. Expected host stdout (not executed): ticks: 5 Common mistake: Using ordinary subtraction that can overflow, or ignoring multiple missed wraps.

Formal Syntax & Structure

rust syntaxrust
now.wrapping_sub(start) >= interval

Working Example

Example Snippetrust
#![no_std]pub fn elapsed(start: u32, now: u32) -> u32 { now.wrapping_sub(start) }
Rust Reference