This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// # Exmaple | |
/// ``` | |
/// select! { | |
/// { $($yes)? } { if_present() } { if_absent() } | |
/// } | |
macro_rules! select { | |
({ $($_:tt)+ } { $($keep:tt)* } { $($discard:tt)* } ) => { $($keep)* }; | |
({} { $($discard:tt)* } { $($keep:tt)* } ) => { $($keep)* }; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[cfg(test)] | |
mod tests { | |
use std::{ | |
sync::{ | |
atomic::{AtomicUsize, Ordering}, | |
Arc, | |
}, | |
time::Duration, | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// creates a nested tuple from the given args | |
/// ``` | |
/// assert_eq!( | |
/// vararg!("a", 15, true, 10.0), | |
/// ("a", (15, (true, (10.0, ())))) | |
/// ) | |
macro_rules! vararg { | |
($first:expr $(, $rest:expr)* $(,)?) => { | |
($first, vararg!( $($rest),* ) ) | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use criterion::{black_box, criterion_group, criterion_main, Criterion}; | |
pub fn concat(v: Vec<Vec<u32>>) -> Vec<u32> { | |
v.concat() | |
} | |
pub fn iter_flatten_collect(v: Vec<Vec<u32>>) -> Vec<u32> { | |
v.into_iter().flatten().collect() | |
} |
OlderNewer