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 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251
//! This crate provides: //! //! - Extension traits for many standard/core library types/traits. //! //! - SelfOps:to extend all types with generic operations. //! //! - Type-level representations of bool and unsafe . //! //! - Marker traits to encode invariants about types. //! //! - etc. //! //! //! # no-std support //! //! To use this crate in no_std contexts disable the default-feature. //! //! # Supported Rust versions //! //! This crate support Rust back to 1.20, //! using a build script to automatically enable features from newer versions. //! //! # Cargo Features //! //! "std":Enables standard library support.Enabled by default. //! //! "serde_":Enables serde support.Disabled by default. //! //! "typenum":Enables trait impls for typenum types.Disabled by default. //! //! //! //! <br></br> //! //! # **Contents** //! //! //! ## Extension trait:[SelfOps](./trait.SelfOps.html) //! //! This is implemented for all types. //! //! The most importand methods in this are: //! //! - [piped](./trait.SelfOps.html#method.piped): //! Allows emulating the pipeline operator. //! //! - [mutated](./trait.SelfOps.html#method.mutated): //! Allows mutating `self` with a closure passing it along the method chain //! //! - [observe](./trait.SelfOps.html#method.observe): //! Observes the value of `self` with a closure passing //! it along the method chain unmodified. //! //! - [into_](./trait.SelfOps.html#method.into_), //! [as_ref_](./trait.SelfOps.html#method.as_ref_), //! [as_mut_](./trait.SelfOps.html#method.as_mut_): //! Alternative syntax for the standard conversion methods. //! //! ## Other extension traits //! //! //! [ResultExt](./option_result_ext/trait.ResultExt.html)::Extension trait for [Result]. //! //! [OptionExt](./option_result_ext/trait.OptionExt.html)::Extension trait for [Option]. //! //! [BoolExt](./bool_extensions/trait.BoolExt.html):Extension trait for bool. //! //! [IntegerExt](./integer_extensions/trait.IntegerExt.html):Extension trait for integers. //! //! [ToTime](./integer_extensions/trait.ToTime.html):Extension trait for integers, to create //! [Duration](::std::time::Duration)s of a certain unit. //! //! [StringExt](./strings/trait.StringExt.html)Extension trait for `str`. //! //! //! ## Marker traits //! //! [MarkerType](./marker_traits/trait.MarkerType.html): //! Represents a zero-sized marker type. //! //! ## Other traits //! //! [ResultLike](./option_result_ext/trait.ResultLike.html): //! Trait for types with item/error values,like Option and Result. //! //! [TransparentNewtype](./transparent_newtype/trait.TransparentNewtype.html) //! Represents a newtype that is safe to transmute to and/from its only non-zero-sized field. //! //! //! //! ## Iteration //! //! [IteratorExt](./iterators/trait.IteratorExt.html) //! Extension trait for [Iterator] implementors. //! //! ### Factories //! //! [IterCloner](./iterators/struct.IterCloner.html): //! Constructs [Iterator]s by cloning the one it references,only possible if it is Clone. //! //! [IterConstructor](./iterators/struct.IterConstructor.html): //! Constructs [Iterator]s using a closure,this can be done multiple times if the closure it Copy. //! //! ### Iterators //! //! [Loop](./iterators/struct.Loop.html): //! Iterator that infinitely produces a value by calling an impl FnMut()->T //! //! [LazyOnce](./iterators/struct.LazyOnce.html): //! Lazy version of [::std::iter::Once],only evaluating the item when //! [Iterator::next] is called. //! //! //! //! ## Type-level stuff //! //! ### Type-Level bool //! //! This crate contains //! [types and operations using type-level `bool`s](./type_level_bool/index.html). //! //! [Boolean](./type_level_bool/trait.Boolean.html): //! Trait representing `bool`. //! //! [True](./type_level_bool/struct.True.html)/ //! [False](./type_level_bool/struct.False.html): //! Types representing `true`/`false`. //! //! ### Type equality //! //! [TypeIdentity](./trait.TypeIdentity.html) //! Allows converting a type back to itself.Useful in generic contexts. //! //! ### Empty type //! //! [Void](./void/enum.Void.html): //! Uninstantiable Type for statically impossible situations. //! Useful as a type parameter/associated type. //! //! //! ### (Un)safety represented as type //! //! [maybe_unsafe](./maybe_unsafe/index.html) emulates a safe/unsafe effect using types. //! //! Allows having traits whose implementations can choose whether their methods/functions //! are safe to call or not. //! //! //! #![deny(missing_docs)] #![deny(unused_imports)] #![deny(unused_must_use)] #![cfg_attr(not(feature = "std"), no_std)] #[cfg(feature = "std")] #[doc(hidden)] pub extern crate std as std_; #[cfg(not(feature = "std"))] #[doc(hidden)] pub extern crate core as std_; #[cfg(feature = "serde_")] extern crate serde; #[cfg(feature = "serde_")] #[macro_use] extern crate serde_derive; #[cfg(feature = "typenum")] extern crate typenum; #[cfg(test)] extern crate rand; #[cfg(test)] #[macro_use] extern crate rand_derive; #[macro_use] mod internal_macros; pub mod bool_extensions; pub mod callable; pub mod integer_extensions; pub mod iterators; pub mod macros; pub mod marker_traits; pub mod maybe_unsafe; #[cfg(any(enable_duration, feature = "std"))] pub mod measure_time; pub mod option_result_ext; pub mod phantom_variances; mod self_ops; pub mod slices; pub mod strings; pub mod transparent_newtype; pub mod try_from; mod type_assert_panic; mod type_identity; pub mod type_level_bool; pub mod utils; pub mod void; /// The items from this crate which are almost always used. pub mod prelude { #[doc(inline)] pub use self_ops::SelfOps; #[doc(inline)] pub use strings::StringExt; #[doc(inline)] pub use marker_traits::MarkerType; #[doc(inline)] pub use type_identity::{TIdentity, TypeIdentity}; #[doc(inline)] pub use phantom_variances::VariantPhantom; #[doc(inline)] pub use type_assert_panic::TypePanic; } pub use self::callable::{CallInto, CallMut, CallRef}; #[doc(inline)] pub use self::self_ops::SelfOps; pub use self::strings::StringExt; #[doc(inline)] pub use type_assert_panic::TypePanic; pub use self::bool_extensions::BoolExt; pub use self::integer_extensions::IntegerExt; #[cfg(any(enable_duration, feature = "std"))] pub use self::integer_extensions::ToTime; pub use self::iterators::{IterCloner, IterConstructor, IteratorExt, LazyOnce}; #[doc(inline)] pub use self::marker_traits::MarkerType; pub use self::option_result_ext::{OptionExt, ResultExt, ResultLike}; pub use self::phantom_variances::{ InvariantPhantom, InvariantRefPhantom, VariantDropPhantom, VariantPhantom, }; pub use self::slices::SliceExt; pub use self::transparent_newtype::TransparentNewtype; pub use self::try_from::{TryFrom, TryInto}; #[doc(inline)] pub use self::type_identity::{TIdentity, TypeIdentity}; pub use self::void::Void;