#literal #data-structure #hashmap #macro

maplit

Collection “literal” macros for HashMap, HashSet, BTreeMap, and BTreeSet

10 releases (3 stable)

Uses old Rust 2015

1.0.2 Aug 24, 2019
1.0.1 Jan 11, 2018
1.0.0 Oct 31, 2017
0.1.6 Oct 27, 2017
0.1.1 May 25, 2015

#53 in Rust patterns

Download history 227028/week @ 2023-10-17 230645/week @ 2023-10-24 237976/week @ 2023-10-31 221824/week @ 2023-11-07 241897/week @ 2023-11-14 208566/week @ 2023-11-21 241808/week @ 2023-11-28 231226/week @ 2023-12-05 222628/week @ 2023-12-12 178036/week @ 2023-12-19 107888/week @ 2023-12-26 193650/week @ 2024-01-02 230566/week @ 2024-01-09 261570/week @ 2024-01-16 263383/week @ 2024-01-23 218867/week @ 2024-01-30

1,011,705 downloads per month
Used in 1,652 crates (651 directly)

MIT/Apache

13KB
157 lines

maplit

Container / collection literal macros for HashMap, HashSet, BTreeMap, BTreeSet.

You can use these for convenience. Using them has no other implications.

Please read the API documentation here

build_status crates

Recent Changes

  • 1.0.2
    • Fix usage of the macros through full paths, like maplit::hashmap!(..) (#27)
  • 1.0.1
    • Fix unused_results lint in the macros by @povilasb
  • 1.0.0
    • maplit 1.0!
    • Only documentation changes since the last version
  • 0.1.6
    • Add macro convert_args! for composable opt-in conversion of the expressions being used for the maplit macros.
  • 0.1.5
    • Add license files correctly
    • Add crates.io category
    • Small doc improvements by @seeekr and @sanmai-NL
  • 0.1.4
    • Update docs to point to docs.rs
  • 0.1.2
    • Now supports more arguments in hashset!{} and hashmap!{}
  • 0.1.0
    • Initial release

FAQ

Question: Very large maps take a long time to compile?

Answer: Rustc is very slow to compile big expressions with many literals (including integers and float literals). Work around this by either using explicitly typed literals, or explicitly typed conversions. See https://github.com/bluss/maplit/issues/14 for more information.

License

Dual-licensed to be compatible with the Rust project.

Licensed under the Apache License, Version 2.0 http://www.apache.org/licenses/LICENSE-2.0 or the MIT license http://opensource.org/licenses/MIT, at your option. This file may not be copied, modified, or distributed except according to those terms.

No runtime deps