The snippet library.
Small, practical examples. Search by task or narrow things down below.
Return a value from a loop
Return a value from a loop in a complete Rust program using the standard library.
Rust✓ Tested
Round and format a decimal value
Round and format a decimal value in a complete Rust program using the standard library.
Rust✓ Tested
Saturate arithmetic at the type boundary
Saturate arithmetic at the type boundary in a complete Rust program using the standard library.
Rust✓ Tested
Search a sorted slice
Search a sorted slice in a complete Rust program using the standard library.
Rust✓ Tested
Send a value through a channel
Send a value through a channel in a complete Rust program using the standard library.
Rust✓ Tested
Share immutable data with Arc
Share immutable data with Arc in a complete Rust program using the standard library.
Rust✓ Tested
Sort a vector in ascending order
Sort a vector in ascending order in a complete Rust program using the standard library.
Rust✓ Tested
Sort and remove repeated values
Sort and remove repeated values in a complete Rust program using the standard library.
Rust✓ Tested
Split a key-value pair once
Split a key-value pair once in a complete Rust program using the standard library.
Rust✓ Tested
Split a slice into two parts
Split a slice into two parts in a complete Rust program using the standard library.
Rust✓ Tested
Split on Unicode whitespace
Split on Unicode whitespace in a complete Rust program using the standard library.
Rust✓ Tested
Stop collecting when parsing fails
Stop collecting when parsing fails in a complete Rust program using the standard library.
Rust✓ Tested