#macro #collection #hash-map #depend #documentation #subject #velcro

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.

9 releases

0.5.4 Jan 1, 2023
0.5.2 Jan 15, 2021
0.5.1 Dec 20, 2020
0.4.2 Dec 9, 2020
0.2.0 Nov 29, 2020

#22 in #subject

Download history 575/week @ 2023-12-13 1119/week @ 2023-12-20 546/week @ 2023-12-27 664/week @ 2024-01-03 938/week @ 2024-01-10 1691/week @ 2024-01-17 1041/week @ 2024-01-24 810/week @ 2024-01-31 1246/week @ 2024-02-07 1727/week @ 2024-02-14 1429/week @ 2024-02-21 1207/week @ 2024-02-28 1367/week @ 2024-03-06 1173/week @ 2024-03-13 1267/week @ 2024-03-20 1442/week @ 2024-03-27

5,419 downloads per month
Used in 34 crates (via velcro)

Unlicense OR MIT

35KB
902 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

~1.5MB
~34K SLoC