std
extensions
Additional features for the Rust standard library.
Description
This crate contains enhancements to the Rust standard library structures, useful for
broad audience, but not yet implemented (or stabilized) in std
.
Crate is designed to be lightweight (no external dependencies!) and provide essential
functionality which possible can get to the std
some day.
The minimal supported Rust version for release 0.3 is 1.53. However, if you need to use this crate with an older version of the compiler, check out release 0.2; there is a good chance that it will suit your needs.
Highlights
-
Integer
super-trait that is implemented for all the built-in integers and reflects the common part of their interfaces.use *;
-
Safe conversions from floating numbers to integers.
use FloatConvert; let valid: = 10.5f32.checked_floor; let too_big: = 256f32.checked_floor; let nan: = f32NAN.checked_floor; assert_eq!; assert_eq!; assert_eq!;
-
Convenient builder methods for
Duration
:use Duration; use *; let duration = from_minutes.add_secs.add_micros; assert_eq!;
-
Panicking version for
RwLock::read
,RwLock::write
andMutex::lock
(for fellows who don't really handle the lock poisoning):use ; use *; let lock = new; let n = lock.force_read; assert_eq!;
-
Result::combine
andOption::combine
to zip pairs of objects:use *; let x = Some; let y = Some; let z = None::; assert_eq!; assert_eq!; let x = Ok; let y = Ok; let z: = Err; let z2: = Err; assert_eq!; assert_eq!; assert_eq!;
-
New handy macros (mostly for development purposes):
use ;
...and other features. For a full list, check out the crate documentation.
Motivation
Standard library is great, and it becomes even better through time. However, a time gap between proposing a new feature and getting it stabilized is way too big.
This crate, however, can be updated quickly and the feature will be usable on the stable Rust soon after implementation.
Contributing
If you want to contribute to this project, please read the contributing guide.
LICENSE
stdext
library is licensed under the MIT License. See LICENSE for details.