Crates.io | std-macro-extensions |
lib.rs | std-macro-extensions |
version | 0.16.0 |
source | src |
created_at | 2024-10-23 13:43:06.336536 |
updated_at | 2024-10-27 22:36:58.425133 |
description | A collection of macro extensions for Rust's standard library data structures, simplifying the creation and manipulation of common collections such as HashMap, Vec, and more. |
homepage | |
repository | https://github.com/ltpp-universe/std-macro-extensions |
max_upload_size | |
id | 1420146 |
size | 28,088 |
A collection of macro extensions for Rust's standard library data structures, simplifying the creation and manipulation of common collections such as HashMap
, Vec
, and more.
Vec
, HashMap
, Arc
, and more.To install std-macro-extensions
run cmd:
cargo add std-macro-extensions
Here are some examples of how to use the macros provided by this crate:
arc!
use std_macro_extensions::*;
fn main() {
let value = arc!(5);
}
b_tree_map!
use std_macro_extensions::*;
fn main() {
let empty_map: BTreeMap<i32, i32> = b_tree_map!();
let b_tree_map_a: BTreeMap<&str, &str> = b_tree_map!(
"a" => "a",
"b" => "b"
);
}
b_tree_set!
use std_macro_extensions::*;
fn main() {
let empty_set: BTreeSet<i32> = b_tree_set!();
let number_set: BTreeSet<i32> = b_tree_set!(1, 2, 3);
}
binary_heap!
use std_macro_extensions::*;
fn main() {
let empty_set: BTreeSet<i32> = b_tree_set!();
let number_set: BTreeSet<i32> = b_tree_set!(1, 2, 3);
}
boxed!
use std_macro_extensions::*;
fn main() {
let boxed_value = boxed!(10);
}
cell!
use std_macro_extensions::*;
fn main() {
let cell_value: Cell<i32> = cell!(5);
}
hash_map!
use std_macro_extensions::*;
fn main() {
let my_map: HashMap<&str, i32> = hash_map!();
let my_map: HashMap<&str, i32> = hash_map!("a" => 1, "b" => 2);
}
hash_set!
use std_macro_extensions::*;
fn main() {
let my_set: HashSet<i32> = hash_set!();
let my_set: HashSet<i32> = hash_set!(1, 2, 3);
}
linked_list!
use std_macro_extensions::*;
fn main() {
let my_list: LinkedList<i32> = linked_list!();
let my_list: LinkedList<i32> = linked_list!(1, 2, 3);
}
mutex!
use std_macro_extensions::*;
fn main() {
let my_mutex: Mutex<i32> = mutex!(5);
let lock: MutexGuard<'_, i32> = my_mutex.lock().unwrap();
}
rc!
use std_macro_extensions::*;
fn main() {
let my_rc = rc!(5);
}
refcell!
use std_macro_extensions::*;
fn main() {
use std_macro_extensions::*;
let my_refcell = refcell!(5);
}
rw_lock!
use std_macro_extensions::*;
fn main() {
let my_rwlock = rw_lock!(5);
}
string!
use std_macro_extensions::*;
fn main() {
let empty_string = string!();
let hello_string = string!("Hello");
}
vector!
use std_macro_extensions::*;
fn main() {
let empty_vector: Vec<i32> = vector!();
let numbers = vector!(1, 2, 3);
}
vector_deque!
use std_macro_extensions::*;
fn main() {
let empty_deque: VecDeque<i32> = vector_deque!();
let numbers = vector_deque!(1, 2, 3);
}
arc!
: Creates an Arc<T>
.vector!
: Creates a Vec<T>
.map!
: Creates a HashMap<K, V>
.set!
: Creates a HashSet<T>
.b_tree_map!
: Creates a BTreeMap<K, V>
.b_tree_set!
: Creates a BTreeSet<T>
.list!
: Creates a LinkedList<T>
.heap!
: Creates a BinaryHeap<T>
.string!
: Creates a String
.boxed!
: Creates a Box<T>
.rc!
: Creates an Rc<T>
.arc!
: Creates an Arc<T>
.mutex!
: Creates a Mutex<T>
.rw_lock!
: Creates a RwLock<T>
.cell!
: Creates a Cell<T>
.ref_cell!
: Creates a RefCell<T>
.vector_deque!
: Creates a VecDeque<T>
.This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! Please open an issue or submit a pull request.
For any inquiries, please reach out to the author at ltpp-universe root@ltpp.vip.