FIND YOUR NEXT FEW LINES

Results for “owner”

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

36 snippets foundClear filters
RustThreads & shared ownership

Read a channel until all senders close

Read a channel until all senders close in a complete Rust program using the standard library.

Rust✓ Tested
C++Ownership & optional values

Read a variant only when it holds the expected type

C++: get_if returns a null pointer rather than throwing for another active alternative.

C++✓ Tested
C++Ownership & optional values

Represent an absent result with optional

C++: value_or supplies a default without requiring a sentinel inside the value domain.

C++✓ Tested
C++Ownership & optional values

Run cleanup through a scoped destructor

C++: A stack object’s destructor runs when its scope exits, including normal exception unwinding.

C++✓ 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
C++Ownership & optional values

Store a reference in a standard container

C++: reference_wrapper preserves reference semantics while behaving like a copyable container element.

C++✓ Tested
CDynamic memory & ownership

Store a variable-length payload after a structure header

C: A flexible array member lets one allocation hold metadata and trailing bytes.

C✓ Tested
CDynamic memory & ownership

Swap owned buffers by swapping their pointers

C: Pointer swaps avoid copying the underlying data.

C✓ Tested
RustThreads & shared ownership

Update an atomic counter

Update an atomic counter in a complete Rust program using the standard library.

Rust✓ Tested
Docker / ComposeNetworks & volume metadata

Label a volume with its purpose

Docker / Compose: Volume labels support explicit ownership and selection.

Docker / Compose✓ Tested
Docker / ComposeBuild images

Run an image as a non-root user

Choose an unprivileged numeric identity for the default process.

Dockerfile✓ Tested