While loop that always executes at least once (do-while loop)?

The best way to replicate do-while loops is with continue expressions.

while (true) : (if ((try std.Io.Clock.Timestamp.now(io, .boot)).compare(.ge, deadline)) break) {
    if (try readMailboxIn(
        port,
        io,
        station_address,
        recv_timeout,
        mbx_in,
    )) |in_content| {
        return in_content;
    }
}
return error.MailboxTimeout;

This method is better and more refactoring-proof than putting the conditional break at the bottom of the loop body, not only because it prevents the break from getting lost in the sauce but also because continue statements won’t inadvertently skip over it.

9 Likes