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

Read a little-endian integer from bytes

Read a little-endian integer from bytes in a complete Rust program using the standard library.

Rust✓ Tested
RustFiles & paths

Read buffered lines from a file

Read buffered lines from a file in a complete Rust program using the standard library.

Rust✓ Tested
RustTesting & reusable patterns

Read bytes through an in-memory cursor

Read bytes through an in-memory cursor in a complete Rust program using the standard library.

Rust✓ Tested
RustFiles & paths

Read file metadata without reading its contents

Read file metadata without reading its contents in a complete Rust program using the standard library.

Rust✓ Tested
RustIterators & transformations

Read values until a condition changes

Read values until a condition changes in a complete Rust program using the standard library.

Rust✓ Tested
RustNumbers & durations

Reject a narrowing integer conversion

Reject a narrowing integer conversion in a complete Rust program using the standard library.

Rust✓ Tested
RustStrings & Unicode

Remove a prefix only when it matches

Remove a prefix only when it matches in a complete Rust program using the standard library.

Rust✓ Tested
RustMaps & sets

Remove an entry and inspect its value

Remove an entry and inspect its value in a complete Rust program using the standard library.

Rust✓ Tested
RustVectors & slices

Remove and collect a vector range

Remove and collect a vector range in a complete Rust program using the standard library.

Rust✓ Tested
RustGetting Started

Repeat while a condition holds

Repeat while a condition holds in a complete Rust program using the standard library.

Rust✓ Tested
RustStrings & Unicode

Replace a literal substring

Replace a literal substring in a complete Rust program using the standard library.

Rust✓ Tested
RustTesting & reusable patterns

Replace a value and keep the old value

Replace a value and keep the old value in a complete Rust program using the standard library.

Rust✓ Tested