Guest User

Untitled

a guest
Jul 20th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #![feature(non_ascii_idents)]
  2.  
  3. struct 人;
  4.  
  5. impl 人 {
  6. fn 有拖鞋(&self) -> bool {
  7. true
  8. }
  9.  
  10. fn 拍死(&self, 蠢货: &mut 虫子) {
  11. 蠢货.活着 = false;
  12. }
  13. }
  14.  
  15. struct 虫子 {
  16. 活着: bool,
  17. }
  18.  
  19. impl 虫子 {
  20. fn 出现了(&self) -> bool {
  21. println!("颤抖吧, 人类! 我一只虫子出现了!");
  22. true
  23. }
  24. }
  25.  
  26. fn main() {
  27. let 我 = 人;
  28. let mut 蟑螂 = 虫子 { 活着: true };
  29.  
  30. if 蟑螂.出现了() && 我.有拖鞋() {
  31. println!("冇有使驚~");
  32. 我.拍死(&mut 蟑螂);
  33. }
  34.  
  35. if !蟑螂.活着 {
  36. println!("哈哈 拍死了!");
  37. }
  38. }
Add Comment
Please, Sign In to add comment