to_unit

Crates.ioto_unit
lib.rsto_unit
version1.0.2
sourcesrc
created_at2022-04-27 03:53:21.176661
updated_at2022-04-27 11:30:14.197906
descriptionToUnit; Any type to () syntax sugar.
homepage
repositoryhttps://github.com/usagi/to_unit
max_upload_size
id575836
size7,191
Usagi Ito (usagi)

documentation

https://docs.rs/to_unit/

README

githubcrates-iodocs-rs
Build Status

ToUnit; drop to the trash syntax sugar for any types.

Example

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.
 //
}

LICENSE

Author

Commit count: 4

cargo fmt