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
//! Trait for copying for ownership
//!
//! This ultimately allows methods to take either references or owned values and still do type
//! inference

pub trait DerefCopy: Copy {
    type Output;
    fn deref_copy(self) -> Self::Output;
}

impl<T: Copy> DerefCopy for &T {
    type Output = T;
    fn deref_copy(self) -> T {
        *self
    }
}

impl DerefCopy for f64 {
    type Output = Self;
    fn deref_copy(self) -> Self {
        self
    }
}

impl DerefCopy for f32 {
    type Output = Self;
    fn deref_copy(self) -> Self {
        self
    }
}