Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #![allow(non_camel_case_types)]
- enum Space_Object {
- Asteroid(Asteroid),
- Spaceship(Spaceship),
- }
- enum Asteroid {
- Asteroid,
- Exploding_Asteroid,
- }
- enum Spaceship {
- Spaceship,
- Apollo_Spacecraft,
- }
- fn collide(a: Space_Object, b: Space_Object) {
- match a {
- Space_Object::Asteroid(a) => {
- match a {
- Asteroid::Asteroid => {
- match b {
- Space_Object::Asteroid(b) => {
- match b {
- Asteroid::Asteroid =>{
- println!("Asteroid hit Asteroid");
- },
- Asteroid::Exploding_Asteroid => {
- println!("Asteroid hit Exploding_Asteroid");
- }};
- },
- Space_Object::Spaceship(b) => {
- match b {
- Spaceship::Spaceship => {
- println!("Asteroid hit Spaceship");
- },
- Spaceship::Apollo_Spacecraft => {
- println!("Asteroid hit Apollo_Spacecraft");
- }};
- }};
- },
- Asteroid::Exploding_Asteroid => {
- match b {
- Space_Object::Asteroid(b) => {
- match b {
- Asteroid::Asteroid =>{
- println!("Exploding_Asteroid hit Asteroid");
- },
- Asteroid::Exploding_Asteroid => {
- println!("Exploding_Asteroid hit Exploding_Asteroid");
- }};
- },
- Space_Object::Spaceship(b) => {
- match b {
- Spaceship::Spaceship => {
- println!("Exploding_Asteroid hit Spaceship");
- },
- Spaceship::Apollo_Spacecraft => {
- println!("Exploding_Asteroid hit Apollo_Spacecraft");
- }};
- }};
- }};
- },
- Space_Object::Spaceship(a) => {
- match a {
- Spaceship::Spaceship => {
- match b {
- Space_Object::Spaceship(b) => {
- match b {
- Spaceship::Spaceship => {
- println!("Spaceship hit Spaceship");
- },
- Spaceship::Apollo_Spacecraft => {
- println!("Spaceship hit Apollo_Spacecraft");
- }};
- },
- Space_Object::Asteroid(b) => {
- match b {
- Asteroid::Asteroid => {
- println!("Spaceship hit Asteroid");
- },
- Asteroid::Exploding_Asteroid => {
- println!("Spaceship hit Exploding_Asteroid");
- }};
- }};
- },
- Spaceship::Apollo_Spacecraft => {
- match b {
- Space_Object::Spaceship(b) => {
- match b {
- Spaceship::Spaceship => {
- println!("Apollo_Spacecraft hit Spaceship");
- },
- Spaceship::Apollo_Spacecraft => {
- println!("Apollo_Spacecraft hit Apollo_Spacecraft");
- }};
- },
- Space_Object::Asteroid(b) => {
- match b {
- Asteroid::Asteroid => {
- println!("Apollo_Spacecraft hit Asteroid");
- },
- Asteroid::Exploding_Asteroid => {
- println!("Apollo_Spacecraft hit Exploding_Asteroid");
- }};
- }};
- }};
- }};
- }
- fn main() {
- {
- let a = Space_Object::Spaceship(Spaceship::Spaceship);
- let b = Space_Object::Spaceship(Spaceship::Spaceship);
- collide(a, b);
- }
- {
- let a = Space_Object::Spaceship(Spaceship::Spaceship);
- let b = Space_Object::Spaceship(Spaceship::Apollo_Spacecraft);
- collide(a, b);
- }
- {
- let a = Space_Object::Spaceship(Spaceship::Spaceship);
- let b = Space_Object::Asteroid(Asteroid::Asteroid);
- collide(a, b);
- }
- {
- let a = Space_Object::Spaceship(Spaceship::Spaceship);
- let b = Space_Object::Asteroid(Asteroid::Exploding_Asteroid);
- collide(a, b);
- }
- {
- let a = Space_Object::Spaceship(Spaceship::Apollo_Spacecraft);
- let b = Space_Object::Spaceship(Spaceship::Spaceship);
- collide(a, b);
- }
- {
- let a = Space_Object::Spaceship(Spaceship::Apollo_Spacecraft);
- let b = Space_Object::Spaceship(Spaceship::Apollo_Spacecraft);
- collide(a, b);
- }
- {
- let a = Space_Object::Spaceship(Spaceship::Apollo_Spacecraft);
- let b = Space_Object::Asteroid(Asteroid::Asteroid);
- collide(a, b);
- }
- {
- let a = Space_Object::Spaceship(Spaceship::Apollo_Spacecraft);
- let b = Space_Object::Asteroid(Asteroid::Exploding_Asteroid);
- collide(a, b);
- }
- {
- let a = Space_Object::Asteroid(Asteroid::Asteroid);
- let b = Space_Object::Spaceship(Spaceship::Spaceship);
- collide(a, b);
- }
- {
- let a = Space_Object::Asteroid(Asteroid::Asteroid);
- let b = Space_Object::Spaceship(Spaceship::Apollo_Spacecraft);
- collide(a, b);
- }
- {
- let a = Space_Object::Asteroid(Asteroid::Asteroid);
- let b = Space_Object::Asteroid(Asteroid::Asteroid);
- collide(a, b);
- }
- {
- let a = Space_Object::Asteroid(Asteroid::Asteroid);
- let b = Space_Object::Asteroid(Asteroid::Exploding_Asteroid);
- collide(a, b);
- }
- {
- let a = Space_Object::Asteroid(Asteroid::Exploding_Asteroid);
- let b = Space_Object::Spaceship(Spaceship::Spaceship);
- collide(a, b);
- }
- {
- let a = Space_Object::Asteroid(Asteroid::Exploding_Asteroid);
- let b = Space_Object::Spaceship(Spaceship::Apollo_Spacecraft);
- collide(a, b);
- }
- {
- let a = Space_Object::Asteroid(Asteroid::Exploding_Asteroid);
- let b = Space_Object::Asteroid(Asteroid::Asteroid);
- collide(a, b);
- }
- {
- let a = Space_Object::Asteroid(Asteroid::Exploding_Asteroid);
- let b = Space_Object::Asteroid(Asteroid::Exploding_Asteroid);
- collide(a, b);
- }
- }
- // =>
- // Spaceship hit Spaceship
- // Spaceship hit Apollo_Spacecraft
- // Spaceship hit Asteroid
- // Spaceship hit Exploding_Asteroid
- // Apollo_Spacecraft hit Spaceship
- // Apollo_Spacecraft hit Apollo_Spacecraft
- // Apollo_Spacecraft hit Asteroid
- // Apollo_Spacecraft hit Exploding_Asteroid
- // Asteroid hit Spaceship
- // Asteroid hit Apollo_Spacecraft
- // Asteroid hit Asteroid
- // Asteroid hit Exploding_Asteroid
- // Exploding_Asteroid hit Spaceship
- // Exploding_Asteroid hit Apollo_Spacecraft
- // Exploding_Asteroid hit Asteroid
- // Exploding_Asteroid hit Exploding_Asteroid
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement