Crates.io | macroland |
lib.rs | macroland |
version | 0.1.5 |
source | src |
created_at | 2023-06-17 20:05:46.477552 |
updated_at | 2023-07-16 23:02:44.544002 |
description | Simple crate for macro shorthands of various types in Rust. |
homepage | https://github.com/OverzealousLotus/Macroland |
repository | https://github.com/OverzealousLotus/Macroland |
max_upload_size | |
id | 893101 |
size | 17,562 |
Macroland is a simple crate with macros to create various Rust types using syntactic sugar. Some of these types offered I do not know about myself, but I have done my best to create a macro for them here. If there are any issues, feel free to report them to my github.
To name a few: hashmap!
, btreeset!
, or arclock!
hashmap!
// I've tried my best to put things where they belong.
use macroland::hashmap;
let my_hashmap = hashmap!(
"Key 1" => "Value 1",
"Key 2" => "Value 2",
"Key 3" => "Value 3",
);
// Alternatively, you can create an "uninitialized" version.
let mut my_hashmap = hashmap!(&str, usize);
my_hashmap.insert("Hello!", 100);
btreemap!
// I've used this before, but I am not entirely sure about the difference with it and HashMaps!
use macroland::btreemap;
let my_btreemap = btreemap!(
"Greetings!" => true,
"How are you?" => false,
"I'm good too." => false,
);
// Like the rest.
let mut my_btreemap = btreemap!(&str, bool);
my_btreemap.insert("Hewwo!", false);
arctex!
// Time to make creating an Arc<Mutex<T>> easier for everyone who has been looking for this!
use macroland::arctex;
let my_arctex = arctex!(vec!["Pizza", "Ice Cream", "Celery"])
// All functionality of an Arc<Mutex<T>> is maintained.
println!("{}", my_arctex.lock().unwrap());
cell!
// Welcome to the wonderful world of celling!
use macroland::cell;
let my_cell = cell!(10);
// Everything works!
my_cell.set(20)
println!("{}", my_cell.get());