FIND YOUR NEXT FEW LINES

The snippet library.

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

125 snippets foundClear filters
RustParsing & byte data

Format an integer as padded hexadecimal

Format an integer as padded hexadecimal in a complete Rust program using the standard library.

Rust✓ Tested
RustGetting Started

Grow a vector

Grow a vector in a complete Rust program using the standard library.

Rust✓ Tested
RustGetting Started

Handle a parsing Result

Handle a parsing Result in a complete Rust program using the standard library.

Rust✓ Tested
RustGetting Started

Handle an optional value

Handle an optional value in a complete Rust program using the standard library.

Rust✓ Tested
RustErrors & optional values

Handle integer overflow without panicking

Handle integer overflow without panicking in a complete Rust program using the standard library.

Rust✓ Tested
RustFunctions & data types

Implement a method on a struct

Implement a method on a struct in a complete Rust program using the standard library.

Rust✓ Tested
RustThreads & shared ownership

Initialize shared data once

Initialize shared data once in a complete Rust program using the standard library.

Rust✓ Tested
RustMaps & sets

Insert and retrieve a map value

Insert and retrieve a map value in a complete Rust program using the standard library.

Rust✓ Tested
RustFiles & paths

Inspect a path’s filename and extension

Inspect a path’s filename and extension in a complete Rust program using the standard library.

Rust✓ Tested
RustVectors & slices

Inspect overlapping windows

Inspect overlapping windows in a complete Rust program using the standard library.

Rust✓ Tested
RustMaps & sets

Iterate over keys in sorted order

Iterate over keys in sorted order in a complete Rust program using the standard library.

Rust✓ Tested
RustThreads & shared ownership

Join a worker thread and read its result

Join a worker thread and read its result in a complete Rust program using the standard library.

Rust✓ Tested