FIND YOUR NEXT FEW LINES

The snippet library.

Small, practical examples. Search by task or narrow things down below.

9 snippets foundClear filters
RustNumbers & durations

Check whether a floating-point value is finite

Check whether a floating-point value is finite in a complete Rust program using the standard library.

Rust✓ Tested
RustNumbers & durations

Clamp a number to a valid interval

Clamp a number to a valid interval in a complete Rust program using the standard library.

Rust✓ Tested
RustNumbers & durations

Construct an instant relative to the Unix epoch

Construct an instant relative to the Unix epoch in a complete Rust program using the standard library.

Rust✓ Tested
RustNumbers & durations

Express a duration in milliseconds

Express a duration in milliseconds in a complete Rust program using the standard library.

Rust✓ Tested
RustNumbers & durations

Reject a narrowing integer conversion

Reject a narrowing integer conversion in a complete Rust program using the standard library.

Rust✓ Tested
RustNumbers & durations

Round and format a decimal value

Round and format a decimal value in a complete Rust program using the standard library.

Rust✓ Tested
RustNumbers & durations

Saturate arithmetic at the type boundary

Saturate arithmetic at the type boundary in a complete Rust program using the standard library.

Rust✓ Tested
RustNumbers & durations

Subtract durations without underflow

Subtract durations without underflow in a complete Rust program using the standard library.

Rust✓ Tested
RustNumbers & durations

Use a nonnegative remainder for cyclic indexing

Use a nonnegative remainder for cyclic indexing in a complete Rust program using the standard library.

Rust✓ Tested