#单位 #类型 #任何 #语法糖

to_unit

ToUnit; 任何类型转换为 () 语法糖

3 个稳定版本

1.0.2 2022年4月27日

#1878 in Rust 模式

Download history 30/week @ 2024-03-11 31/week @ 2024-03-18 37/week @ 2024-03-25 70/week @ 2024-04-01 13/week @ 2024-04-08 43/week @ 2024-04-15 29/week @ 2024-04-22 22/week @ 2024-04-29 12/week @ 2024-05-06 16/week @ 2024-05-13 8/week @ 2024-05-20 31/week @ 2024-05-27 17/week @ 2024-06-03 18/week @ 2024-06-10 18/week @ 2024-06-17 30/week @ 2024-06-24

88 每月下载量
用于 actix-web-tonic

MIT 许可证

5KB

githubcrates-iodocs-rs
Build Status

ToUnit; 任何类型的转换为垃圾语法糖。

示例

use to_unit::ToUnit;
// or, `use to_unit::ToUnit as __` for ultra lzay persons!

#[test]
fn match_arms_to_easily()
{
 use std::collections::HashMap;
 let mut x = HashMap::<String, i32>::new();
 x.insert("neko".to_string(), 123);
 match x.get_mut("neko")
 {
  Some(v) => *v = 222,
  None => x.insert("neko".to_string(), 222).to_unit() // <-- here!
 }
 // Ofcorse alternatively, you can write:
 //  eg. None => { x.insert("neko".to_string(), 222); }
 // But, it might be fix to a multi-line format by rust-fmt then...:
 //  eg. None => {
 //          x.insert("neko".to_string(), 222);
 //      }
 // I don't like the multi-line behaviors, so I made the __ lib.
 //
}

许可证

作者

无运行时依赖