Skip to content

Latest commit

 

History

History
54 lines (37 loc) · 855 Bytes

README.md

File metadata and controls

54 lines (37 loc) · 855 Bytes

set! macro Rust crate

This crate provides set! macros to create set collections and insert elements. This is inspired by the vec! macro.

set! macro

Create a new set collection and insert elements.

Example with tuple syntax:

let m = set!((1, 2), (3, 4));

Example with arrow syntax:

let m = set!(1 => 2, 3 => 4);

Equivalent Rust standard code:

let mut m = HashSet::new();
m.insert(1, 2);
m.insert(3, 4);

set_insert! macro

Use an existing set collection and insert elements.

Example with tuple syntax:

let mut m = HashSet::new();
set_insert!(m, (1, 2), (3, 4));

Example with arrow syntax:

let mut m = HashSet::new();
set_insert!(m, 1 => 2, 3 => 4);

Equivalent Rust std code with method `insert``:

let mut m = HashSet::new();
m.insert(1, 2);
m.insert(3, 4);