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
JavaEncoding & structured values

Encode and decode Base64 bytes

Java: Convert through UTF-8 explicitly before and after Base64 encoding.

Java✓ Tested
Arduino / CBinary values & packets

Extract the low and high byte of a value

Arduino / C: lowByte and highByte expose the two bytes of a 16-bit value.

Arduino / C✓ Tested
CDynamic memory & ownership

Grow an allocation without losing it on failure

C: Assign realloc to a temporary pointer so the original allocation remains available if growth fails.

C✓ Tested
CDynamic memory & ownership

Initialize a byte buffer to zero

C: memset initializes each byte to the chosen unsigned-char value.

C✓ Tested
RustThreads & shared ownership

Initialize shared data once

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

Rust✓ Tested
C++Containers & compound values

Insert a map value only when a key is absent

C++: try_emplace preserves the old value when insertion does not take place.

C++✓ Tested
JavaEncoding & structured values

Inspect components of a URI

Java: Use URI parsing instead of splitting a URL at punctuation manually.

Java✓ 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
JavaEncoding & structured values

Measure UTF-8 bytes separately from characters

Java: Encode a Java string before measuring its serialized byte length.

Java✓ Tested
RustThreads & shared ownership

Move owned data into a worker

Move owned data into a worker in a complete Rust program using the standard library.

Rust✓ Tested
JavaEncoding & structured values

Parse a UUID and inspect its version

Java: Use UUID.fromString for a standard UUID value.

Java✓ Tested
C++Containers & compound values

Process a first-in first-out queue

C++: Queue exposes its front item separately from the operation that removes it.

C++✓ Tested