FIND YOUR NEXT FEW LINES

Results for “Containers & compound values”

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

432 snippets foundClear filters
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
RustErrors & optional values

Handle integer overflow without panicking

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

Rust✓ Tested
JavaEncoding & structured values

Inspect components of a URI

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

Java✓ Tested
RustErrors & optional values

Keep an optional value only when valid

Keep an optional value only when valid 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
C++Ownership & optional values

Observe shared ownership without extending its lifetime

C++: A weak_ptr can be locked while an owner exists and becomes expired after the last owner is released.

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

Own one dynamically allocated value with unique_ptr

C++: make_unique allocates a value whose lifetime is tied to its owning smart pointer.

C++✓ Tested
JavaEncoding & structured values

Parse a UUID and inspect its version

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

Java✓ Tested
RustErrors & optional values

Propagate a parsing error with question mark

Propagate a parsing error with question mark in a complete Rust program using the standard library.

Rust✓ Tested
RustErrors & optional values

Provide a default for a missing value

Provide a default for a missing value 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
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