11 releases (5 breaking)
Uses old Rust 2015
0.6.1 | Jul 6, 2017 |
---|---|
0.6.0 |
|
0.5.0 | May 9, 2017 |
0.4.0 | Apr 13, 2017 |
0.1.0 | Mar 6, 2017 |
#2128 in Data structures
3,539 downloads per month
Used in 14 crates
(9 directly)
30KB
398 lines
Len
trait
Len
trait for collections. You may freely use and modify this code under the
CC0 1.0 Universal License.
Usage
To use in your own project, just add the below to your Cargo.toml
file.
[dependencies]
len-trait = "0.6"
For more formal documentation, you can find the rustdoc here.
lib.rs
:
This crate generalises traits over the len
and capacity
methods found in most collections.
Methods that are included:
capacity
clear
is_empty
len
reserve_exact
reserve
shrink_to_fit
split_at_mut
split_at
split_off
truncate
with_capacity
Additionally, the traits IndexRange<Idx>
and IndexRangeMut<Idx>
are provided for
"consistent slicing," i.e. slicing over all range types.
Modules
The len
module provides:
The capacity
module provides:
CapacityMut
, which requiresWithCapacity
WithCapacity
, which requiresCapacity
Capacity
, which requiresLen
.
The index
module provides:
IndexRange<Idx>
, automatically implemented fromIndex<Idx>
IndexRangeMut<Idx>
, automatically implemented fromIndexMut<Idx>
SplitAt<Idx>
, which requiresIndexRange<Idx>
SplitAtMut<Idx>
, which requiresIndexRangeMut<Idx>
Features
The alloc
and std
features offer different tiers of implementations for different
collections. The std
feature automatically enables alloc
. Although the std
feature is the
default, disabling it will enable no_std
.
Dependencies
~8KB