1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
//! 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 [`IndexRanges<Idx>`] and [`IndexRangesMut<Idx>`] are provided for //! "consistent slicing," i.e. slicing over all range types. //! //! # Modules //! //! The `len` module provides: //! //! * [`LenMut`], which requires `Clear` //! * [`Clear`], which requires `Len` //! * [`Len`], which requires `Empty` //! * [`Empty`] //! //! The `capacity` module provides: //! //! * [`CapacityMut`], which requires `WithCapacity` //! * [`WithCapacity`], which requires `Capacity` //! * [`Capacity`], which requires `Len`. //! //! The `index` module provides: //! //! * [`IndexRanges<Idx>`], automatically implemented from `Index<Idx>` //! * [`IndexRangesMut<Idx>`], automatically implemented from `IndexMut<Idx>` //! * [`SplitAt<Idx>`], which requires `IndexRanges<Idx>` //! * [`SplitAtMut<Idx>`], which requires [`IndexRangesMut<Idx>`] //! //! # Trait table //! //! | type | `len` | `capacity` | `index` | //! |-----------------|----------|---------------|--------------| //! | `String` | `LenMut` | `CapacityMut` | X | //! | `VecDeque` | `LenMut` | `CapacityMut` | X | //! | `Vec` | `LenMut` | `CapacityMut` | X | //! | `BinaryHeap` | `Clear` | `CapacityMut` | X | //! | `BitSet` | `Clear` | `CapacityMut` | X | //! | `BitVec` | `Clear` | `CapacityMut` | X | //! | `HashMap` | `Clear` | `CapacityMut` | X | //! | `HashSet` | `Clear` | `CapacityMut` | X | //! | `IntervalHeap` | `Clear` | `CapacityMut` | X | //! | `LinearMap` | `Clear` | `CapacityMut` | X | //! | `LinkedHashMap` | `Clear` | `CapacityMut` | X | //! | `OsString` | `Clear` | `CapacityMut` | X | //! | `VecMap` | `Clear` | `CapacityMut` | X | //! | `BList` | `Clear` | X | X | //! | `BTreeMap` | `Clear` | X | X | //! | `BTreeSet` | `Clear` | X | X | //! | `EnumSet` | `Clear` | X | X | //! | `LinkedList` | `Clear` | X | X | //! | `LruCache` | `Clear` | X | X | //! | `[T]` | `Len` | X | `SplitAtMut` | //! | `str` | `Len` | X | `SplitAtMut` | //! | `CStr` | `Len` | X | X | //! | `CString` | `Len` | X | X | //! | `OsStr` | `Len` | X | X | //! //! //! [`LenMut`]: len/trait.LenMut.html //! [`Clear`]: len/trait.Clear.html //! [`Len`]: len/trait.Len.html //! [`Empty`]: len/trait.Empty.html //! [`CapacityMut`]: capacity/trait.CapacityMut.html //! [`WithCapacity`]: capacity/trait.WithCapacity.html //! [`Capacity`]: capacity/trait.Capacity.html //! [`SplitAt<Idx>`]: index/trait.SplitAt.html //! [`SplitAtMut<Idx>`]: index/trait.SplitAtMut.html //! [`IndexRanges<Idx>`]: index/trait.IndexRanges.html //! [`IndexRangesMut<Idx>`]: index/trait.IndexRangesMut.html //! [`capacity`]: capacity/trait.Capacity.html#tymethod.capacity //! [`clear`]: len/trait.Clear.html#tymethod.clear //! [`is_empty`]: len/trait.Empty.html#method.is_empty //! [`len`]: len/trait.Len.html#tymethod.len //! [`reserve_exact`]: capacity/trait.CapacityMut.html#method.reserve_exact //! [`reserve`]: capacity/trait.CapacityMut.html#tymethod.reserve //! [`shrink_to_fit`]: capacity/trait.CapacityMut.html#method.shrink_to_fit //! [`split_at_mut`]: index/trait.SplitAtMut.html#tymethod.split_at_mut //! [`split_at`]: index/trait.SplitAt.html#tymethod.split_at //! [`split_off`]: len/trait.LenMut.html#tymethod.split_off //! [`truncate`]: len/trait.LenMut.html#tymethod.truncate //! [`with_capacity`]: capacity/trait.WithCapacity.html#tymethod.with_capacity #![cfg_attr(all(not(feature = "std"), feature = "collections"), feature(collections))] #![cfg_attr(feature = "nightly", feature(inclusive_range))] #![cfg_attr(all(feature = "nightly", feature = "std"), feature(osstring_shrink_to_fit))] #![cfg_attr(not(feature = "std"), feature(core_slice_ext, core_str_ext))] #![cfg_attr(not(feature = "std"), no_std)] #![doc(html_root_url = "https://docs.charr.xyz/len-trait/")] #![deny(warnings)] #[cfg(feature = "bit-set")] extern crate bit_set; #[cfg(feature = "bit-vec")] extern crate bit_vec; #[cfg(feature = "blist")] extern crate blist; #[cfg(feature = "enum-set")] extern crate enum_set; #[cfg(feature = "interval-heap")] extern crate interval_heap; #[cfg(feature = "linear-map")] extern crate linear_map; #[cfg(feature = "linked-hash-map")] extern crate linked_hash_map; #[cfg(feature = "lru-cache")] extern crate lru_cache; #[cfg(feature = "vec_map")] extern crate vec_map; #[cfg(all(not(feature = "std"), feature = "collections"))] extern crate collections; pub mod capacity; pub mod index; pub mod len; pub use capacity::*; pub use index::*; pub use len::*; mod impls;