Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #![feature(non_ascii_idents)]
- struct 人;
- impl 人 {
- fn 有拖鞋(&self) -> bool {
- true
- }
- fn 拍死(&self, 蠢货: &mut 虫子) {
- 蠢货.活着 = false;
- }
- }
- struct 虫子 {
- 活着: bool,
- }
- impl 虫子 {
- fn 出现了(&self) -> bool {
- println!("颤抖吧, 人类! 我一只虫子出现了!");
- true
- }
- }
- fn main() {
- let 我 = 人;
- let mut 蟑螂 = 虫子 { 活着: true };
- if 蟑螂.出现了() && 我.有拖鞋() {
- println!("冇有使驚~");
- 我.拍死(&mut 蟑螂);
- }
- if !蟑螂.活着 {
- println!("哈哈 拍死了!");
- }
- }
Add Comment
Please, Sign In to add comment