You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
structPerson{name:String,age:u8,}traitHasVoiceBox{fnspeak(&self);fncan_speak(&self) -> bool;}implHasVoiceBoxforPerson{fnspeak(&self){println!("Hello, my name is {}.", self.name);}// This does not runfncan_speak(&self) -> bool{
!matches!(self.age, 0..=2)}}implPerson{// This runsfncan_speak(&self) -> bool{matches!(self.age, 0..=2)}}fnmain(){let person = Person{name:String::from("Bob"),age:3,};/* Returns false, there should be an error or warning of some sort on the functions that won't run and unused traits*/println!("Can {} speak? {}", person.name, person.can_speak());}
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: