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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
use std::option::Option;
use std::marker::PhantomData;

pub trait Param {
    type Param;
}

pub trait ReParam<B>: Param {
    type Output: Param<Param=B>;
}

impl<'a, A: Param> Param for &'a A {
    type Param = A::Param;
}

impl<'a, A: Param> Param for &'a mut A {
    type Param = A::Param;
}

impl<A> Param for Option<A> {
    type Param = A;
}

impl<A, B> ReParam<B> for Option<A> {
    type Output = Option<B>;
}

impl<X, A> Param for (X, A) {
    type Param = A;
}

impl<X, A, B> ReParam<B> for (X, A) {
    type Output = (X, B);
}

impl<A> Param for PhantomData<A> {
    type Param = A;
}

impl<A, B> ReParam<B> for PhantomData<A> {
    type Output = PhantomData<B>;
}

impl<A> Param for Box<A> {
    type Param = A;
}

impl<A, B> ReParam<B> for Box<A> {
    type Output = Box<B>;
}

impl<A, E> Param for Result<A, E> {
    type Param = A;
}

impl<A, B, E> ReParam<B> for Result<A, E> {
    type Output = Result<B, E>;
}