Advertisement
Guest User

Untitled

a guest
May 27th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. pub struct Bot {
  2. name : String,
  3. lifetime : u32,
  4. }
  5.  
  6. pub trait BotInfo {
  7. fn bot_info (&self) -> String
  8. {
  9. String::from("name : {}\nlifetime : {}\n", self.name, self.lifetime)
  10. }
  11. }
  12.  
  13. impl BotInfo for Bot {}
  14.  
  15. fn main ()
  16. {
  17.  
  18. let bot : Bot = Bot {
  19. name : String::from("bot"),
  20. lifetime : 12,
  21. };
  22.  
  23. bot.bot_info();
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement