3 releases
Uses old Rust 2015
0.1.2 | Feb 26, 2025 |
---|---|
0.1.1 | Feb 26, 2025 |
0.1.0 | Feb 26, 2025 |
#446 in No standard library
438 downloads per month
11KB
57 lines
Gan - 干就完了! / Just do it!
帮助开发者更果決地处理返回值的实用库。提供符合人体工程学的快捷方法来忽略结果/快速构造默认值。 A pragmatic Rust library that helps developers handle return values decisively. Provides ergonomic methods to ignore results or construct default values with semantic shortcuts.
快速入门 Quick Start
在 Cargo.toml
添加(Add to your Cargo.toml):
[dependencies]
gan = "0.1"
用法示例 Usage Examples
操作 | 表达式示例 | 返回类型 | 示例用途 |
---|---|---|---|
忽略结果 | expr.ignore() |
() |
format!("{}", 42).ignore(); |
构造 Ok 单元 | expr.ok() |
Result<(), E> |
write!(file, "{}", data)?.ok() |
构造 Ok 单元 | result.ignore().ok() |
Result<(), E> |
write!(file, "{}", data).ignore().ok() |
构造 Ok 包裹 | expr.okay() |
Result<T, E> |
42.okay() |
构造 Some 值 | expr.some() |
Option<T> |
42.some() |
构造 None 值 | expr.none() |
Option<U> |
42.none() |
Operation | Expression Example | Return Type | Example Use Case |
---|---|---|---|
Ignore Result | expr.ignore() |
() |
format!("{}", 42).ignore(); |
Construct Ok Unit | expr.ok() |
Result<(), E> |
write!(file, "{}", data)?.ok() |
Construct Ok Unit | result.ignore().ok() |
Result<(), E> |
write!(file, "{}", data).ignore().ok() |
Construct Ok Wrapped | expr.okay() |
Result<T, E> |
42.okay() |
Construct Some Value | expr.some() |
Option<T> |
42.some() |
Construct None Value | expr.none() |
Option<U> |
42.none() |
开源协议 License
MIT License © 2024 允许商业使用/修改/分发,无担保责任 Permits commercial use/modification/distribution with no warranty