1 unstable release
0.1.0 | Dec 21, 2023 |
---|
#2814 in Rust patterns
Used in 2 crates
7KB
A Rust library crate that offers the MapSelf
trait, implemented on all types.
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
lib.rs
:
Example:
let (hour, meridiem) = if use_12_hour_clock {
self.hour_meridiem() // Yields 12-hour clock time.
.map_self(|(hour, meridiem)| (hour, Some(meridiem)))
} else {
(self.hour, None)
};
Example:
// Initialize time to check for double-click.
let mut last_click_time = Instant::now()
.map_self_or_keep(|now| now.checked_sub(Duration::from_secs(60)));