#options #utilities #collection

option-utils

一组用于处理 Rust 的 Option 类型的实用工具

1 个不稳定版本

0.1.0 2023年5月5日

#46 in #option

Download history 64/week @ 2024-03-11 61/week @ 2024-03-18 107/week @ 2024-03-25 97/week @ 2024-04-01 69/week @ 2024-04-08 48/week @ 2024-04-15 66/week @ 2024-04-22 58/week @ 2024-04-29 62/week @ 2024-05-06 78/week @ 2024-05-13 51/week @ 2024-05-20 68/week @ 2024-05-27 47/week @ 2024-06-03 51/week @ 2024-06-10 49/week @ 2024-06-17 72/week @ 2024-06-24

220 每月下载量
21 包(3 个直接使用)中使用

Apache-2.0

5KB
64

option-utils

一组用于处理 Rust 的 Option 类型的实用工具

示例

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:

一组用于处理 Rust 的 Option 类型的实用工具。

示例

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));

许可

此项目采用 Apache-2.0 许可证。

无运行时依赖