| Crates.io | hurry |
| lib.rs | hurry |
| version | 0.1.3 |
| created_at | 2025-11-06 22:07:29.32853+00 |
| updated_at | 2025-11-06 23:02:02.954653+00 |
| description | Convenient macros for creating pointer types (Box, Rc, Arc, etc.) |
| homepage | |
| repository | https://github.com/sweetpeteza/hurry |
| max_upload_size | |
| id | 1920808 |
| size | 30,483 |
Convenient macros for creating pointer types (Box, Rc, Arc, etc.) in Rust.
Add this to your Cargo.toml:
[dependencies]
hurry = "0.1.3"
To use the procedural macro for generating custom shorthand macros, enable the macros feature:
[dependencies]
hurry = { version = "0.1.3", features = ["macros"] }
The hurry crate provides convenient macros for creating common pointer types:
use hurry::*;
// Create a Box
let boxed = boxx!(42);
assert_eq!(*boxed, 42);
// Create an Rc
let shared = rc!(String::from("hello"));
let clone = shared.clone();
assert_eq!(*shared, "hello");
// Create an Arc
let atomic = arc!(vec![1, 2, 3]);
let thread_clone = atomic.clone();
// Can be safely shared across threads
use hurry::*;
// Rc<RefCell<T>> for single-threaded interior mutability
let cell = rc_refcell!(0);
*cell.borrow_mut() += 10;
assert_eq!(*cell.borrow(), 10);
// Arc<Mutex<T>> for thread-safe interior mutability
let mutex = arc_mutex!(0);
*x.lock().unwrap() += 20;
assert_eq!(*x.lock().unwrap(), 20);
// Arc<RwLock<T>> for thread-safe read-write access
let rwlock = arc_rwlock!(0);
*x.write().unwrap() += 30;
assert_eq!(*x.read().unwrap(), 30);
The hurry crate also provides a procedural macro for generating shorthand macros for your own types:
use hurry_macros::shorthand;
struct MyType {
value: i32,
}
#[shorthand]
impl MyType {
pub fn new(value: i32) -> Self {
MyType { value }
}
}
// This generates a `my_type!` macro for creating instances
let instance = my_type!(42);
assert_eq!(instance.value, 42);
The #[shorthand] attribute generates a macro named after the type in snake_case that calls the new method.
boxx!(value) → Box::new(value)rc!(value) → Rc::new(value)arc!(value) → Arc::new(value)rc_refcell!(value) → Rc<RefCell<T>>::new(RefCell::new(value))arc_mutex!(value) → Arc<Mutex<T>>::new(Mutex::new(value))arc_rwlock!(value) → Arc<RwLock<T>>::new(RwLock::new(value))mutex!(value) → Mutex::new(value)rwlock!(value) → RwLock::new(value)cell!(value) → Cell::new(value)refcell!(value) → RefCell::new(value)pin_box!(value) → Box::pin(value)vec_box!(values...) → vec![Box::new(value), ...]vec_rc!(values...) → vec![Rc::new(value), ...]vec_arc!(values...) → vec![Arc::new(value), ...]cow_owned!(value) → Cow::Owned(value)cow_borrowed!(value) → Cow::Borrowed(value)#[shorthand] → Generates a shorthand macro for types with a new methodFull API documentation is available at docs.rs/hurry.
Licensed under either of:
at your option.
Contributions are welcome! Please feel free to submit a Pull Request.