#unit #type #any #syntax-sugar

to_unit

ToUnit; Any type to () syntax sugar

3 stable releases

1.0.2 Apr 27, 2022

#2652 in Rust patterns

Download history 21/week @ 2024-07-21 109/week @ 2024-07-28 22/week @ 2024-08-04 22/week @ 2024-08-11 17/week @ 2024-08-18 19/week @ 2024-08-25 16/week @ 2024-09-01 21/week @ 2024-09-08 22/week @ 2024-09-15 33/week @ 2024-09-22 45/week @ 2024-09-29 14/week @ 2024-10-06 12/week @ 2024-10-13 16/week @ 2024-10-20 15/week @ 2024-10-27 9/week @ 2024-11-03

53 downloads per month
Used in actix-web-tonic

MIT license

5KB

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

No runtime deps