Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct Kiwi;
- impl Kiwi {
- fn greet(&mut self) {
- println!("Hello Fellas!");
- }
- fn eat(&self) {
- println!("I feel it in my code.");
- }
- }
- trait Fruit {
- fn greet(&self) {
- println!("I love fruits!");
- }
- fn eat(&self) {
- println!("I feel it in my pulp.");
- }
- }
- impl Fruit for Kiwi {}
- fn main() {
- let mut kiwi = Kiwi;
- kiwi.greet();
- (&mut kiwi).greet();
- kiwi.eat();
- (&kiwi as &Fruit).eat();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement