The snippet library.
Small, practical examples. Search by task or narrow things down below.
Capture a surrounding value in a closure
Capture a surrounding value in a closure in a complete Rust program using the standard library.
Rust✓ Tested
Chain operations that may return None
Chain operations that may return None in a complete Rust program using the standard library.
Rust✓ Tested
Change a path’s extension
Change a path’s extension in a complete Rust program using the standard library.
Rust✓ Tested
Check a deterministic result with an assertion
Check a deterministic result with an assertion in a complete Rust program using the standard library.
Rust✓ Tested
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
Choose an action with match
Choose an action with match in a complete Rust program using the standard library.
Rust✓ Tested
Choose floating-point arithmetic
Choose floating-point arithmetic in a complete Rust program using the standard library.
Rust✓ Tested
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
Clone an owned value explicitly
Clone an owned value explicitly in a complete Rust program using the standard library.
Rust✓ Tested
Collect borrowed values into owned strings
Collect borrowed values into owned strings in a complete Rust program using the standard library.
Rust✓ Tested
Collect unique sorted values
Collect unique sorted values in a complete Rust program using the standard library.
Rust✓ Tested
Combine Boolean conditions
Combine Boolean conditions in a complete Rust program using the standard library.
Rust✓ Tested