The snippet library.
Small, practical examples. Search by task or narrow things down below.
Parse a delimited integer record
Parse a delimited integer record in a complete Rust program using the standard library.
Rust✓ Tested
Parse a hexadecimal integer
Parse a hexadecimal integer in a complete Rust program using the standard library.
Rust✓ Tested
Parse a signed decimal integer
Parse a signed decimal integer in a complete Rust program using the standard library.
Rust✓ Tested
Parse only valid integers
Parse only valid integers in a complete Rust program using the standard library.
Rust✓ Tested
Partition values into two collections
Partition values into two collections in a complete Rust program using the standard library.
Rust✓ Tested
Print a collection for inspection
Print a collection for inspection in a complete Rust program using the standard library.
Rust✓ Tested
Process a slice in bounded chunks
Process a slice in bounded chunks in a complete Rust program using the standard library.
Rust✓ Tested
Propagate a parsing error with question mark
Propagate a parsing error with question mark in a complete Rust program using the standard library.
Rust✓ Tested
Protect shared mutable state with a mutex
Protect shared mutable state with a mutex in a complete Rust program using the standard library.
Rust✓ Tested
Provide a default for a missing value
Provide a default for a missing value in a complete Rust program using the standard library.
Rust✓ Tested
Query an ordered map’s key range
Query an ordered map’s key range in a complete Rust program using the standard library.
Rust✓ Tested
Read a channel until all senders close
Read a channel until all senders close in a complete Rust program using the standard library.
Rust✓ Tested