more_collection_macros

Crates.iomore_collection_macros
lib.rsmore_collection_macros
version0.2.2
sourcesrc
created_at2022-01-30 03:17:12.408266
updated_at2022-02-15 06:27:07.331439
descriptionAdds new macros to rust for creating collections
homepage
repositoryhttps://github.com/joshradin/more_collection_macros
max_upload_size
id523874
size9,046
Joshua Radin (joshradin)

documentation

README

More Collection Macros

By Joshua Radin

Repostiory

This library provides a set of useful macros for creating std collections, similar to the default vec! macro

Comprehension

These macros enable list/map comprehension similar to what's present in python. For example, the following python code

list = [x*x for x in range(0,10)]
dict = {x : x*x for x in range(0,10)}

is equivalent to the following rust code

let list = list![x*x; x in 0..10];
let dict = map!{x => x*x; x in 0..10};

Namespace-like

With maps, you can also use identifiers as keys, which are then converted to &'static str keys.

map!{
    field1: 0,
    field2: 1
};

You can't repeat fields with this notation. The following will give a runtime error.

map!{
    field1: 0,
    field1: 1
};
Commit count: 11

cargo fmt