FIND YOUR NEXT FEW LINES

The snippet library.

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

125 snippets foundClear filters
RustFunctions & data types

Define behavior with a trait

Define behavior with a trait in a complete Rust program using the standard library.

Rust✓ Tested
RustFunctions & data types

Derive comparison and debugging behavior

Derive comparison and debugging behavior in a complete Rust program using the standard library.

Rust✓ Tested
RustGetting Started

Destructure a tuple

Destructure a tuple in a complete Rust program using the standard library.

Rust✓ Tested
RustParsing & byte data

Detect invalid UTF-8 data

Detect invalid UTF-8 data in a complete Rust program using the standard library.

Rust✓ Tested
RustStrings & Unicode

Distinguish UTF-8 bytes from characters

Distinguish UTF-8 bytes from characters in a complete Rust program using the standard library.

Rust✓ Tested
RustParsing & byte data

Encode an integer as big-endian bytes

Encode an integer as big-endian bytes in a complete Rust program using the standard library.

Rust✓ Tested
RustTesting & reusable patterns

Exercise a function with a table of inputs

Exercise a function with a table of inputs in a complete Rust program using the standard library.

Rust✓ Tested
RustNumbers & durations

Express a duration in milliseconds

Express a duration in milliseconds in a complete Rust program using the standard library.

Rust✓ Tested
RustMaps & sets

Find common set members

Find common set members in a complete Rust program using the standard library.

Rust✓ Tested
RustMaps & sets

Find members missing from another set

Find members missing from another set in a complete Rust program using the standard library.

Rust✓ Tested
RustIterators & transformations

Find the first matching value

Find the first matching value in a complete Rust program using the standard library.

Rust✓ Tested
RustIterators & transformations

Flatten nested collections

Flatten nested collections in a complete Rust program using the standard library.

Rust✓ Tested