summaryrefslogtreecommitdiff
path: root/meap/meap-code/ch3/ch3-newtype-pattern.rs
blob: 9647b27926806c13574c9c1837d64e153967ce68 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
#[derive(PartialEq)] // <1>
struct Hostname(String); // <2>

fn main() {
    let ordinary_string = String::from("localhost"); 
    let host = Hostname ( ordinary_string.clone() );
    if host == ordinary_string { // <3>
      println!("huh?");
    };
}