1 unstable release
Uses old Rust 2015
0.1.0 | Jun 12, 2018 |
---|
#24 in #hold
8KB
179 lines
holds
A Rust library to introduce the Holds
trait.
This library is not tested or very documented at this point. Use at your own risk.
Usage
Add the following to your Cargo.toml
:
[dependencies]
holds = "0.1"
and then add this to your crate root:
extern crate holds;
lib.rs
:
This small library provides the Holds
trait, which can be
implemented for a type that contains another value. This trait is meant for
"Range"-like types. Obviously Rust's Range*
types fit this definition,
but slices like [T]
and str
do too (they contain a starting reference
and a length, and contain a number of subslices or discrete values in
between their start and end points).
Holds
exposes the holds
method, which returns a bool
representing whether the value was held within. This library also provides
the Reassign
trait, which is a subtrait of Holds
.
Reassign
is intended soley for references, so that the lifetime of a
value reference can be extended if it's held by a container that lives
longer. reassign
therefore takes &'a self
and &'b T
and returns
Option
<
&'a T
>
.