Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/harryfei/sugar-rs
Rust syntax sugar collections.
https://github.com/harryfei/sugar-rs
macro rust sugar syntax
Last synced: 3 months ago
JSON representation
Rust syntax sugar collections.
- Host: GitHub
- URL: https://github.com/harryfei/sugar-rs
- Owner: harryfei
- Created: 2018-01-08T14:49:35.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-05-07T09:08:19.000Z (over 5 years ago)
- Last Synced: 2024-06-19T05:14:11.106Z (5 months ago)
- Topics: macro, rust, sugar, syntax
- Language: Rust
- Homepage:
- Size: 16.6 KB
- Stars: 130
- Watchers: 8
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Sugar
Syntax sugar to make your Rust life more sweet.
## Usage
```rust
use sugar::*;
```
## Overview```rust
use sugar::*;// vec of boxed value
let vb1 = vec_box![1, 2, 3];// vec/list comprehension
let vb2 = v![Box::new(i), for i in 1..4];// hashmap construction
let hm1 = hashmap!{
1 => 2,
2 => 3,
3 => 4,
};// hashmap comprehension
let hm2 = m!{i => i + 1, for i in 1..4};let _ = max!(1, 2, 3);
let _ = min!(1, 2, 3);if cmp!(1, < num, < 3) {
println!("num is between 1 and 3");
}```
More detail in sugar's [documentation](https://docs.rs/sugar).