#hashmap #collections #macros #literal #literals #vector #collection

macro velcro_macros

Procedural macros used by the velcro crate. See velcro for documentation. It is not advised to depend on this crate directly; it is an internal dependency of velcro and may be subject to breaking changes.

8 unstable releases (3 breaking)

0.5.2 Jan 15, 2021
0.5.1 Dec 20, 2020
0.4.2 Dec 9, 2020
0.3.0 Dec 2, 2020
0.2.0 Nov 29, 2020

#816 in Data structures

Download history 562/week @ 2022-04-22 833/week @ 2022-04-29 272/week @ 2022-05-06 439/week @ 2022-05-13 308/week @ 2022-05-20 478/week @ 2022-05-27 339/week @ 2022-06-03 424/week @ 2022-06-10 247/week @ 2022-06-17 224/week @ 2022-06-24 199/week @ 2022-07-01 280/week @ 2022-07-08 247/week @ 2022-07-15 346/week @ 2022-07-22 261/week @ 2022-07-29 237/week @ 2022-08-05

1,138 downloads per month
Used in 23 crates (via velcro)

Unlicense OR MIT

34KB
900 lines

Velcro

Build Status

A set of macros for conveniently initializing collections from Rust's std and iterators. All of the macros support the unary .. operator which "spreads" the values of another collection or iterator.

velcro::vec! is a drop-in replacement for std::vec!. All functionality of the std macro is supported without overhead, but it also supports spreading values with the .. operator.

Examples

use velcro::{hash_map, iter, vec};

assert_eq!(vec![0, 1, ..(2..7)], vec![0, 1, 2, 3, 4, 5, 6]);

let other = vec![3, 4, 5];
assert_eq!(vec![0, 1, 2, ..&other, 6], vec![0, 1, 2, 3, 4, 5, 6]);

let whitespace = iter![' ', '\t', '\r', '\n'];
let map = hash_map! {
    ..('0'..='9'): "digit",
    ..('a'..='z'): "lower",
    ..('A'..='Z'): "upper",
    ..whitespace: "whitespace",
    '.': "punctuation",
    ',': "punctuation",
};

assert_eq!(map[&'x'], "lower");
assert_eq!(map[&'\r'], "whitespace");
assert_eq!(map[&'.'], "punctuation");

Help

For help, questions or to report an issue, please use the Github issue tracker.

Dependencies

~215–620KB
~15K SLoC