#![allow(unused_variables,dead_code)] type Username = String; enum DBLookup { Result { usr: Username, major: String, gpa :f32 }, PrivacyRequested(Username), NoSuchEntry{}, DatabaseDown(), } fn main() -> () { let result1: DBLookup = DBLookup::NoSuchEntry{}; let result2: DBLookup = DBLookup::PrivacyRequested(String::from("ibarland")); let result3: DBLookup = DBLookup::Result{usr: String::from("jchase"), major: String::from("CSAT"), gpa: 3.9}; println!( "{}", match &result2 { DBLookup::Result { usr, major, gpa } => &usr, DBLookup::PrivacyRequested(u) => &u, DBLookup::NoSuchEntry{} => "they don't exist", DBLookup::DatabaseDown() => "cannot connect; try later." } ); println!("hi"); } // Note: Here are two correct ways to do LinkedLists: enum LinkedList { Empty(), Cons{ first: T, rest: Box> } } // OR, rather than a type LinkedList, use `>`: // struct Cons { val: T, next: Option>> }