gan 0.1.2

Just do it! A small tool provides ergonomic value handling with ignore/ ok/ some semantics.
Documentation
  • Coverage
  • 100%
    7 out of 7 items documented5 out of 6 items with examples
  • Size
  • Source code size: 10.69 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.16 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 9s Average build duration of successful builds.
  • all releases: 8s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • muyuanjin/gan
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • muyuanjin

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