Results for “owner”
Small, practical examples. Search by task or narrow things down below.
Borrow text without transferring ownership
Borrow text without transferring ownership in a complete Rust program using the standard library.
Rust✓ Tested
Make a script executable by its owner
Linux Commands: Add the owner execute bit without replacing all permission bits.
Linux Commands✓ Tested
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
Set copied files’ numeric ownership
Docker / Compose: COPY --chown sets ownership while adding the file.
Docker / Compose✓ Tested
Set owner-only file permissions
Linux Commands: Use chmod 600 to allow only the owner to read and write a file.
Linux Commands✓ Tested
Set owner-only read and write permissions
C++: Replace ordinary permission bits with the requested owner permissions.
C++✓ Tested
Share ownership with a counted smart pointer
C++: Copies of shared_ptr keep the owned value alive until the last owner is released.
C++✓ Tested
Transfer unique ownership with move
C++: Moving a unique_ptr leaves the source empty and gives ownership to the destination.
C++✓ Tested
Allocate an independent copy of a C string
C: Include one extra byte for the terminating null character.
C✓ Tested
Allocate and free a typed array
C: Use sizeof on the pointed-to type and check allocation success before writing.
C✓ Tested
Allocate and initialize a structure
C: Use a compound literal assignment to initialize all ordinary structure fields.
C✓ Tested
Apply an operation to a variant’s active value
C++: A generic visitor lets the compiler check behavior for every possible alternative.
C++✓ Tested