| Crates.io | benri |
| lib.rs | benri |
| version | 0.1.12 |
| created_at | 2023-04-02 19:54:22.560861+00 |
| updated_at | 2023-05-18 16:26:17.61302+00 |
| description | Convenient macros wrapping the standard library |
| homepage | |
| repository | https://github.com/hinto-janai/benri |
| max_upload_size | |
| id | 828572 |
| size | 32,477 |
benriConvenient macros wrapping the standard library.
This library provides convenient macros!() around std functionality.
| Flag | Purpose |
|---|---|
log |
Enable log usage in certain places |
let mut a = false;
flip!(a);
assert!(a == true);
flip!(a);
assert!(a == false);
Instant:let now = now!();
std::thread::sleep(std::time::Duration::from_secs(1));
assert!(now.elapsed().as_secs() >= 1);
Instant time:let now = now!();
std::thread::sleep(std::time::Duration::from_secs(1));
assert!(secs!(now) >= 1);
assert!(secs_f64!(now) >= 1.0);
assert!(millis!(now) >= 1000);
assert!(micros!(now) >= 10000);
assert!(nanos!(now) >= 100000);
let now = now!();
// This sleeps the current thread for 1 second.
sleep!(1000);
assert!(secs!(now) >= 1);
std::thread::spawn(|| {
mass_panic!();
}).join().unwrap();
// The program will has already exited.
// The below statement will never be reached.
unsafe { /* do bad things */ }
mass_panic!():This works with any channel (like crossbeam_channel) that
have the same method names as the std channels since the inner macro is calling .send() and .recv().
let (tx, rx) = std::sync::mpsc::channel::<u8>();
std::thread::spawn(move || {
send!(tx, 255);
}).join().unwrap();
assert!(recv!(rx) == 255);