The snippet library.
Small, practical examples. Search by task or narrow things down below.
Store data in an enum variant
Store data in an enum variant in a complete Rust program using the standard library.
Rust✓ Tested
Subtract durations without underflow
Subtract durations without underflow in a complete Rust program using the standard library.
Rust✓ Tested
Take Unicode characters without byte slicing
Take Unicode characters without byte slicing in a complete Rust program using the standard library.
Rust✓ Tested
Transform a value by shadowing
Transform a value by shadowing in a complete Rust program using the standard library.
Rust✓ Tested
Transform an optional value
Transform an optional value in a complete Rust program using the standard library.
Rust✓ Tested
Transform each value with map
Transform each value with map in a complete Rust program using the standard library.
Rust✓ Tested
Transpose an optional parsing result
Transpose an optional parsing result in a complete Rust program using the standard library.
Rust✓ Tested
Trim whitespace around text
Trim whitespace around text in a complete Rust program using the standard library.
Rust✓ Tested
Update an atomic counter
Update an atomic counter in a complete Rust program using the standard library.
Rust✓ Tested
Update an existing map value
Update an existing map value in a complete Rust program using the standard library.
Rust✓ Tested
Update an explicitly mutable variable
Update an explicitly mutable variable in a complete Rust program using the standard library.
Rust✓ Tested
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