summaryrefslogtreecommitdiff
path: root/ex4_9/src/main.rs
blob: 08e47b512aa82d6837f22c31d161b47242207534 (plain)
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
pub struct WrappingU32 {
    value: u32,
}

impl From<u32> for WrappingU32 {
    fn from(v: u32) -> Self {
        Self{value:v}
    }
}

fn main() {
    println!("Hello, world!");
}

#[cfg(test)]
mod tests {
    use crate::*;

    #[test]
    fn t0() {
        let n: u32 = 5;
        let w: WrappingU32 = n.into();
        assert_eq!(w.value,n);
    }
}