#options #utilities #collection

option-utils

A collection of utilities for working with Rust's Option type

1 unstable release

0.1.0 May 5, 2023

#137 in #options

Download history 51/week @ 2024-07-22 47/week @ 2024-07-29 41/week @ 2024-08-05 61/week @ 2024-08-12 37/week @ 2024-08-19 37/week @ 2024-08-26 35/week @ 2024-09-02 38/week @ 2024-09-09 39/week @ 2024-09-16 59/week @ 2024-09-23 39/week @ 2024-09-30 1/week @ 2024-10-07 23/week @ 2024-10-14 37/week @ 2024-10-21 25/week @ 2024-10-28 30/week @ 2024-11-04

115 downloads per month
Used in 21 crates (3 directly)

Apache-2.0

5KB
64 lines

option-utils

A collection of utilities for working with Rust's Option type

Example

use option_utils::OptionUtils;
let mut x = Some("Hello world".to_owned());
x.inner_mut(|s| s.push('!'));
assert_eq!(x, Some("Hello world!".to_owned()));

let path = Some("dir");
let path: Option<std::path::PathBuf> = path.map_into();
assert_eq!(path, Some(std::path::Path::new("dir").to_owned()));

let num = Some(10_u64);
let num: Option<u8> = num.try_map_into()?;
assert_eq!(num, Some(10_u8));```

## License

This project is licensed under the Apache-2.0 license.

lib.rs:

A collection of utilities for working with Rust's Option type.

Example

use option_utils::OptionUtils;

let mut x = Some("Hello world".to_owned());
x.inner_mut(|s| s.push('!'));
assert_eq!(x, Some("Hello world!".to_owned()));

let path = Some("dir");
let path: Option<std::path::PathBuf> = path.map_into();
assert_eq!(path, Some(std::path::Path::new("dir").to_owned()));

let num = Some(10_u64);
let num: Option<u8> = num.try_map_into().unwrap();
assert_eq!(num, Some(10_u8));

License

This project is licensed under the Apache-2.0 license.

No runtime deps