Crate write_only

Source
Expand description

References/slices that provide write-access, but no read-access.

§Examples

Write-only reference:

use write_only::{prelude::*, Put};

fn write<T: Put<u8>>(write_only: &mut T) {
    write_only.put(42u8);
}

let mut value: u8 = 0;

let mut write_only = WriteOnlyRef::from(&mut value);
write(&mut write_only);

assert_eq!(value, 42);

Write-only slice:

use write_only::{prelude::*, PutAt};

fn write<T: PutAt<u8>>(write_only: &mut T) {
    write_only.put_at(2, 42u8);
}

let mut values: Vec<u8> = (0..10).collect();

let mut write_only = WriteOnlySlice::from(&mut values[..]);
write(&mut write_only);

assert_eq!(values[2], 42u8);

Modules§

prelude
The crate’s prelude.

Structs§

VolatileWriteOnlyRef
A write-only reference with non-dropping volatile write access.
VolatileWriteOnlySlice
A write-only slice with non-dropping volatile write access.
WriteOnlyRef
A write-only reference with dropping non-volatile write access.
WriteOnlySlice
A write-only slice with dropping non-volatile write access.

Traits§

Put
A trait for objects which provide dropping write access to their value.
PutAt
A trait for objects which provide dropping indexed write access to their values.
PutFromSliceAt
A trait for objects which provide dropping indexed write access to their values from a slice.
Write
A trait for objects which provide non-dropping write access to their value.
WriteAt
A trait for objects which provide non-dropping indexed write access to their values.
WriteFromSliceAt
A trait for objects which provide non-dropping indexed write access to their values from a slice.