gan

Crates.iogan
lib.rsgan
version0.1.2
created_at2025-02-26 08:46:29.581022+00
updated_at2025-02-26 10:46:45.361922+00
descriptionJust do it! A small tool provides ergonomic value handling with ignore/ ok/ some semantics.
homepagehttps://github.com/muyuanjin/gan
repositoryhttps://github.com/muyuanjin/gan
max_upload_size
id1570142
size11,216
muyuanjin (muyuanjin)

documentation

https://docs.rs/gan

README

Gan - 干就完了! / Just do it!

Crates.io Docs.rs

帮助开发者更果決地处理返回值的实用库。提供符合人体工程学的快捷方法来忽略结果/快速构造默认值。 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

Commit count: 8

cargo fmt