option-utils

Crates.iooption-utils
lib.rsoption-utils
version0.1.0
sourcesrc
created_at2023-05-05 15:18:13.988187
updated_at2023-05-05 15:18:13.988187
descriptionA collection of utilities for working with Rust's Option type
homepage
repositoryhttps://github.com/jsoverson/option-utils
max_upload_size
id857832
size4,311
Jarrod Overson (jsoverson)

documentation

README

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.
Commit count: 1

cargo fmt