len_trait/
lib.rs

1//! This crate generalises traits over the `len` and `capacity` methods found in most collections.
2//!
3//! Methods that are included:
4//!
5//! * [`capacity`]
6//! * [`clear`]
7//! * [`is_empty`]
8//! * [`len`]
9//! * [`reserve_exact`]
10//! * [`reserve`]
11//! * [`shrink_to_fit`]
12//! * [`split_at_mut`]
13//! * [`split_at`]
14//! * [`split_off`]
15//! * [`truncate`]
16//! * [`with_capacity`]
17//!
18//! Additionally, the traits [`IndexRange<Idx>`] and [`IndexRangeMut<Idx>`] are provided for
19//! "consistent slicing," i.e. slicing over all range types.
20//!
21//! # Modules
22//!
23//! The `len` module provides:
24//!
25//! * [`LenMut`], which requires `Clear`
26//! * [`Clear`], which requires `Len`
27//! * [`Len`], which requires `Empty`
28//! * [`Empty`]
29//!
30//! The `capacity` module provides:
31//!
32//! * [`CapacityMut`], which requires `WithCapacity`
33//! * [`WithCapacity`], which requires `Capacity`
34//! * [`Capacity`], which requires `Len`.
35//!
36//! The `index` module provides:
37//!
38//! * [`IndexRange<Idx>`], automatically implemented from `Index<Idx>`
39//! * [`IndexRangeMut<Idx>`], automatically implemented from `IndexMut<Idx>`
40//! * [`SplitAt<Idx>`], which requires `IndexRange<Idx>`
41//! * [`SplitAtMut<Idx>`], which requires `IndexRangeMut<Idx>`
42//!
43//! # Features
44//!
45//! The `alloc` and `std` features offer different tiers of implementations for different
46//! collections. The `std` feature automatically enables `alloc`. Although the `std` feature is the
47//! default, disabling it will enable `no_std`.
48//!
49//! [`LenMut`]: len/trait.LenMut.html
50//! [`Clear`]: len/trait.Clear.html
51//! [`Len`]: len/trait.Len.html
52//! [`Empty`]: len/trait.Empty.html
53//! [`CapacityMut`]: capacity/trait.CapacityMut.html
54//! [`WithCapacity`]: capacity/trait.WithCapacity.html
55//! [`Capacity`]: capacity/trait.Capacity.html
56//! [`SplitAt<Idx>`]: index/trait.SplitAt.html
57//! [`SplitAtMut<Idx>`]: index/trait.SplitAtMut.html
58//! [`IndexRange<Idx>`]: index/trait.IndexRange.html
59//! [`IndexRangeMut<Idx>`]: index/trait.IndexRangeMut.html
60//! [`capacity`]: capacity/trait.Capacity.html#tymethod.capacity
61//! [`clear`]: len/trait.Clear.html#tymethod.clear
62//! [`is_empty`]: len/trait.Empty.html#tymethod.is_empty
63//! [`len`]: len/trait.Len.html#tymethod.len
64//! [`reserve_exact`]: capacity/trait.CapacityMut.html#method.reserve_exact
65//! [`reserve`]: capacity/trait.CapacityMut.html#tymethod.reserve
66//! [`shrink_to_fit`]: capacity/trait.CapacityMut.html#method.shrink_to_fit
67//! [`split_at_mut`]: index/trait.SplitAtMut.html#tymethod.split_at_mut
68//! [`split_at`]:  index/trait.SplitAt.html#tymethod.split_at
69//! [`split_off`]: len/trait.LenMut.html#tymethod.split_off
70//! [`truncate`]: len/trait.LenMut.html#tymethod.truncate
71//! [`with_capacity`]: capacity/trait.WithCapacity.html#tymethod.with_capacity
72#![cfg_attr(all(not(feature = "std"), feature = "alloc"), feature(alloc))]
73#![cfg_attr(not(feature = "std"), feature(core_slice_ext, core_str_ext))]
74#![cfg_attr(not(feature = "std"), no_std)]
75#![doc(html_root_url = "https://docs.charr.xyz/len-trait/")]
76#![cfg_attr(test, deny(warnings))]
77
78#[macro_use]
79extern crate cfg_if;
80
81#[cfg(feature = "bit-set")]
82extern crate bit_set;
83
84#[cfg(feature = "bit-vec")]
85extern crate bit_vec;
86
87#[cfg(feature = "blist")]
88extern crate blist;
89
90#[cfg(feature = "enum-set")]
91extern crate enum_set;
92
93#[cfg(feature = "interval-heap")]
94extern crate interval_heap;
95
96#[cfg(feature = "linear-map")]
97extern crate linear_map;
98
99#[cfg(feature = "linked-hash-map")]
100extern crate linked_hash_map;
101
102#[cfg(feature = "lru-cache")]
103extern crate lru_cache;
104
105#[cfg(feature = "vec_map")]
106extern crate vec_map;
107
108#[cfg(all(not(feature = "std"), feature = "alloc"))]
109extern crate alloc;
110
111pub mod capacity;
112pub mod index;
113pub mod len;
114
115pub use capacity::*;
116pub use index::*;
117pub use len::*;
118
119mod impls;