2 releases
Uses old Rust 2015
0.1.1 | Oct 28, 2018 |
---|---|
0.1.0 | Oct 28, 2018 |
#5 in #write-only
4KB
write_ref
Support for write-only references in Rust.
lib.rs
:
Write-only references.
Many functions in Rust's standard library, such as char::encode_utf8
, take
a mutable reference that they only ever write to.
This crate provides a way to express this guarantee:
WriteRef<T>
provides a single method,write
. By taking this as a parameter, a function guarantees that it will only ever write to it.WriteSlice<T>
works similarly, but it allows writing only to individual elements. This is useful for functions that write to a provided buffer, such aschar::encode_utf8
.
Most functions should not take a WriteRef
or WriteSlice
directly;
instead, they should take an impl Into<WriteRef<'a, T>>
so that callers
can pass in a &mut T
.