#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

#93 in #options

Download history 50/week @ 2023-12-13 53/week @ 2023-12-20 25/week @ 2023-12-27 24/week @ 2024-01-03 44/week @ 2024-01-10 34/week @ 2024-01-17 26/week @ 2024-01-24 21/week @ 2024-01-31 37/week @ 2024-02-07 52/week @ 2024-02-14 49/week @ 2024-02-21 68/week @ 2024-02-28 67/week @ 2024-03-06 58/week @ 2024-03-13 90/week @ 2024-03-20 90/week @ 2024-03-27

308 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