FIND YOUR NEXT FEW LINES

The snippet library.

Small, practical examples. Search by task or narrow things down below.

125 snippets foundClear filters
RustGetting Started

Return a value from a loop

Return a value from a loop in a complete Rust program using the standard library.

Rust✓ Tested
RustNumbers & durations

Round and format a decimal value

Round and format a decimal value in a complete Rust program using the standard library.

Rust✓ Tested
RustNumbers & durations

Saturate arithmetic at the type boundary

Saturate arithmetic at the type boundary in a complete Rust program using the standard library.

Rust✓ Tested
RustVectors & slices

Search a sorted slice

Search a sorted slice in a complete Rust program using the standard library.

Rust✓ Tested
RustThreads & shared ownership

Send a value through a channel

Send a value through a channel in a complete Rust program using the standard library.

Rust✓ Tested
RustThreads & shared ownership

Share immutable data with Arc

Share immutable data with Arc in a complete Rust program using the standard library.

Rust✓ Tested
RustVectors & slices

Sort a vector in ascending order

Sort a vector in ascending order in a complete Rust program using the standard library.

Rust✓ Tested
RustVectors & slices

Sort and remove repeated values

Sort and remove repeated values in a complete Rust program using the standard library.

Rust✓ Tested
RustStrings & Unicode

Split a key-value pair once

Split a key-value pair once in a complete Rust program using the standard library.

Rust✓ Tested
RustVectors & slices

Split a slice into two parts

Split a slice into two parts in a complete Rust program using the standard library.

Rust✓ Tested
RustStrings & Unicode

Split on Unicode whitespace

Split on Unicode whitespace in a complete Rust program using the standard library.

Rust✓ Tested
RustErrors & optional values

Stop collecting when parsing fails

Stop collecting when parsing fails in a complete Rust program using the standard library.

Rust✓ Tested