N.B. this crate requires nightly, as it makes use of
FnBox and untagged unions.
thunk: Generic lazy evaluation for Rust
thunk crate provides primitives for lazy evaluation in Rust.
At present, it provides five thunk types and three traits which abstract lazily
Lazy. The thunk types are as follows:
RcThunk: a reference-counted, cloneable thunk. An
RcThunk<T>is essentially an
Rc<Thunk<T>>; however, it implements
Send + Syncthunks which use atomic data internally. This is slower than
RcThunk. Essentially an
Send + Sync, paradoxically strict thunks.
Strictdoesn't actually defer anything, and is provided to make it simpler to write code which is generic over strictness.
The provided traits -
Lazy - abstract immutable
references to lazy values, mutable references to lazy values, and owned lazy
values, respectively. For example,
RcThunk only implements
LazyRef. All traits take a lifetime
parameter; this is a bandaid to cover Rust's current lack of associated lifetimes.
This parameter bounds the lifetime of the closure object representing a deferred
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.