write-only

Crates.iowrite-only
lib.rswrite-only
version0.1.0
sourcesrc
created_at2021-10-26 23:07:00.322229
updated_at2021-10-26 23:07:00.322229
descriptionReferences/slices that provide write-access, but no read-access.
homepage
repositoryhttps://github.com/regexident/write-only
max_upload_size
id472210
size57,838
Vincent Esche (regexident)

documentation

README

write-only

Checks Downloads Version License

Synopsis

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

Motivation

Sometimes is is desirable to only provide write-access to a value or slice of values without also providing read-access..

This is where write-only comes in handy!

Usage

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);

Contributing

Please read CONTRIBUTING.md for details on our code of conduct,
and the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

License

This project is licensed under the MPL-2.0 – see the LICENSE.md file for details.

Commit count: 18

cargo fmt