The snippet library.
Small, practical examples. Search by task or narrow things down below.
Read a little-endian integer from bytes
Read a little-endian integer from bytes in a complete Rust program using the standard library.
Rust✓ Tested
Read buffered lines from a file
Read buffered lines from a file in a complete Rust program using the standard library.
Rust✓ Tested
Read bytes through an in-memory cursor
Read bytes through an in-memory cursor in a complete Rust program using the standard library.
Rust✓ Tested
Read file metadata without reading its contents
Read file metadata without reading its contents in a complete Rust program using the standard library.
Rust✓ Tested
Read values until a condition changes
Read values until a condition changes in a complete Rust program using the standard library.
Rust✓ Tested
Reject a narrowing integer conversion
Reject a narrowing integer conversion in a complete Rust program using the standard library.
Rust✓ Tested
Remove a prefix only when it matches
Remove a prefix only when it matches in a complete Rust program using the standard library.
Rust✓ Tested
Remove an entry and inspect its value
Remove an entry and inspect its value in a complete Rust program using the standard library.
Rust✓ Tested
Remove and collect a vector range
Remove and collect a vector range in a complete Rust program using the standard library.
Rust✓ Tested
Repeat while a condition holds
Repeat while a condition holds in a complete Rust program using the standard library.
Rust✓ Tested
Replace a literal substring
Replace a literal substring in a complete Rust program using the standard library.
Rust✓ Tested
Replace a value and keep the old value
Replace a value and keep the old value in a complete Rust program using the standard library.
Rust✓ Tested