1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
use crate::Dummy;
use rand::Rng;
use std::cell::{Cell, RefCell};
use std::ops::Deref;
use std::pin::Pin;
use std::rc::Rc;
use std::sync::{Arc, Mutex, RwLock};
macro_rules! container_impl {
($ptr:ident) => {
impl<T, U> Dummy<U> for $ptr<T>
where
T: Dummy<U>,
{
fn dummy_with_rng<R: Rng + ?Sized>(config: &U, rng: &mut R) -> Self {
$ptr::new(T::dummy_with_rng(config, rng))
}
}
};
}
container_impl!(Box);
container_impl!(Cell);
container_impl!(RefCell);
container_impl!(Rc);
container_impl!(Arc);
container_impl!(Mutex);
container_impl!(RwLock);
impl<T, U> Dummy<U> for Pin<T>
where
T: Dummy<U> + Deref,
<T as Deref>::Target: Unpin,
{
fn dummy_with_rng<R: Rng + ?Sized>(config: &U, rng: &mut R) -> Self {
Pin::new(T::dummy_with_rng(config, rng))
}
}