FIND YOUR NEXT FEW LINES

Results for “Ownership & optional values”

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

359 snippets foundClear filters
RustThreads & shared ownership

Protect shared mutable state with a mutex

Protect shared mutable state with a mutex in a complete Rust program using the standard library.

Rust✓ Tested
JavaEncoding & structured values

Read a big-endian integer from bytes

Java: Set a byte order explicitly when handling a binary protocol.

Java✓ Tested
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
JavaScriptObjects & JSON

Read a nested value safely

Combine optional chaining with nullish coalescing in JavaScript.

JavaScript✓ Tested
C++Containers & compound values

Remove a map entry and inspect the number removed

C++: erase by key reports whether a unique-key map contained the entry.

C++✓ Tested
Arduino / CBinary values & packets

Require every bit in a mask

Arduino / C: Masking followed by equality tests whether all required flags are set.

Arduino / 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
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
C++Containers & compound values

Store and inspect a fixed set of bits

C++: bitset offers named operations and a readable binary representation.

C++✓ Tested
CDynamic memory & ownership

Swap owned buffers by swapping their pointers

C: Pointer swaps avoid copying the underlying data.

C✓ Tested
Arduino / CBinary values & packets

Toggle a bit with an XOR mask

Arduino / C: XOR flips selected bits and leaves all other bits unchanged.

Arduino / C✓ Tested