The snippet library.
Small, practical examples. Search by task or narrow things down below.
Destructure a tuple
Destructure a tuple in a complete Rust program using the standard library.
Rust✓ Tested
Grow a vector
Grow a vector in a complete Rust program using the standard library.
Rust✓ Tested
Handle a parsing Result
Handle a parsing Result in a complete Rust program using the standard library.
Rust✓ Tested
Handle an optional value
Handle an optional value in a complete Rust program using the standard library.
Rust✓ Tested
Loop over an inclusive range
Loop over an inclusive range in a complete Rust program using the standard library.
Rust✓ Tested
Match enum variants
Match enum variants in a complete Rust program using the standard library.
Rust✓ Tested
Modify a value through a mutable borrow
Modify a value through a mutable borrow 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
Repeat while a condition holds
Repeat while a condition holds in a complete Rust program using the standard library.
Rust✓ Tested
Return a value from a loop
Return a value from a loop 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
Update an explicitly mutable variable
Update an explicitly mutable variable in a complete Rust program using the standard library.
Rust✓ Tested