Advertisement
Guest User

Untitled

a guest
Jun 27th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.59 KB | None | 0 0
  1. #![allow(non_camel_case_types)]
  2.  
  3. enum Space_Object {
  4. Asteroid(Asteroid),
  5. Spaceship(Spaceship),
  6. }
  7.  
  8. enum Asteroid {
  9. Asteroid,
  10. Exploding_Asteroid,
  11. }
  12.  
  13. enum Spaceship {
  14. Spaceship,
  15. Apollo_Spacecraft,
  16. }
  17.  
  18. fn collide(a: Space_Object, b: Space_Object) {
  19.  
  20. match a {
  21. Space_Object::Asteroid(a) => {
  22.  
  23. match a {
  24. Asteroid::Asteroid => {
  25.  
  26. match b {
  27. Space_Object::Asteroid(b) => {
  28.  
  29. match b {
  30. Asteroid::Asteroid =>{
  31. println!("Asteroid hit Asteroid");
  32. },
  33.  
  34. Asteroid::Exploding_Asteroid => {
  35. println!("Asteroid hit Exploding_Asteroid");
  36. }};
  37. },
  38.  
  39. Space_Object::Spaceship(b) => {
  40.  
  41. match b {
  42. Spaceship::Spaceship => {
  43. println!("Asteroid hit Spaceship");
  44. },
  45.  
  46. Spaceship::Apollo_Spacecraft => {
  47. println!("Asteroid hit Apollo_Spacecraft");
  48. }};
  49. }};
  50. },
  51.  
  52. Asteroid::Exploding_Asteroid => {
  53.  
  54. match b {
  55. Space_Object::Asteroid(b) => {
  56.  
  57. match b {
  58. Asteroid::Asteroid =>{
  59. println!("Exploding_Asteroid hit Asteroid");
  60. },
  61.  
  62. Asteroid::Exploding_Asteroid => {
  63. println!("Exploding_Asteroid hit Exploding_Asteroid");
  64. }};
  65. },
  66.  
  67. Space_Object::Spaceship(b) => {
  68.  
  69. match b {
  70. Spaceship::Spaceship => {
  71. println!("Exploding_Asteroid hit Spaceship");
  72. },
  73.  
  74. Spaceship::Apollo_Spacecraft => {
  75. println!("Exploding_Asteroid hit Apollo_Spacecraft");
  76. }};
  77. }};
  78. }};
  79. },
  80.  
  81. Space_Object::Spaceship(a) => {
  82.  
  83. match a {
  84. Spaceship::Spaceship => {
  85.  
  86. match b {
  87. Space_Object::Spaceship(b) => {
  88.  
  89. match b {
  90. Spaceship::Spaceship => {
  91. println!("Spaceship hit Spaceship");
  92. },
  93.  
  94. Spaceship::Apollo_Spacecraft => {
  95. println!("Spaceship hit Apollo_Spacecraft");
  96. }};
  97. },
  98.  
  99. Space_Object::Asteroid(b) => {
  100.  
  101. match b {
  102. Asteroid::Asteroid => {
  103. println!("Spaceship hit Asteroid");
  104. },
  105.  
  106. Asteroid::Exploding_Asteroid => {
  107. println!("Spaceship hit Exploding_Asteroid");
  108. }};
  109. }};
  110. },
  111.  
  112. Spaceship::Apollo_Spacecraft => {
  113.  
  114. match b {
  115. Space_Object::Spaceship(b) => {
  116.  
  117. match b {
  118. Spaceship::Spaceship => {
  119. println!("Apollo_Spacecraft hit Spaceship");
  120. },
  121.  
  122. Spaceship::Apollo_Spacecraft => {
  123. println!("Apollo_Spacecraft hit Apollo_Spacecraft");
  124. }};
  125. },
  126.  
  127. Space_Object::Asteroid(b) => {
  128.  
  129. match b {
  130. Asteroid::Asteroid => {
  131. println!("Apollo_Spacecraft hit Asteroid");
  132. },
  133.  
  134. Asteroid::Exploding_Asteroid => {
  135. println!("Apollo_Spacecraft hit Exploding_Asteroid");
  136. }};
  137. }};
  138. }};
  139. }};
  140.  
  141. }
  142.  
  143. fn main() {
  144. {
  145. let a = Space_Object::Spaceship(Spaceship::Spaceship);
  146. let b = Space_Object::Spaceship(Spaceship::Spaceship);
  147. collide(a, b);
  148. }
  149.  
  150. {
  151. let a = Space_Object::Spaceship(Spaceship::Spaceship);
  152. let b = Space_Object::Spaceship(Spaceship::Apollo_Spacecraft);
  153. collide(a, b);
  154. }
  155.  
  156. {
  157. let a = Space_Object::Spaceship(Spaceship::Spaceship);
  158. let b = Space_Object::Asteroid(Asteroid::Asteroid);
  159. collide(a, b);
  160. }
  161.  
  162. {
  163. let a = Space_Object::Spaceship(Spaceship::Spaceship);
  164. let b = Space_Object::Asteroid(Asteroid::Exploding_Asteroid);
  165. collide(a, b);
  166. }
  167.  
  168. {
  169. let a = Space_Object::Spaceship(Spaceship::Apollo_Spacecraft);
  170. let b = Space_Object::Spaceship(Spaceship::Spaceship);
  171. collide(a, b);
  172. }
  173.  
  174. {
  175. let a = Space_Object::Spaceship(Spaceship::Apollo_Spacecraft);
  176. let b = Space_Object::Spaceship(Spaceship::Apollo_Spacecraft);
  177. collide(a, b);
  178. }
  179.  
  180. {
  181. let a = Space_Object::Spaceship(Spaceship::Apollo_Spacecraft);
  182. let b = Space_Object::Asteroid(Asteroid::Asteroid);
  183. collide(a, b);
  184. }
  185.  
  186. {
  187. let a = Space_Object::Spaceship(Spaceship::Apollo_Spacecraft);
  188. let b = Space_Object::Asteroid(Asteroid::Exploding_Asteroid);
  189. collide(a, b);
  190. }
  191.  
  192. {
  193. let a = Space_Object::Asteroid(Asteroid::Asteroid);
  194. let b = Space_Object::Spaceship(Spaceship::Spaceship);
  195. collide(a, b);
  196. }
  197.  
  198. {
  199. let a = Space_Object::Asteroid(Asteroid::Asteroid);
  200. let b = Space_Object::Spaceship(Spaceship::Apollo_Spacecraft);
  201. collide(a, b);
  202. }
  203.  
  204. {
  205. let a = Space_Object::Asteroid(Asteroid::Asteroid);
  206. let b = Space_Object::Asteroid(Asteroid::Asteroid);
  207. collide(a, b);
  208. }
  209.  
  210. {
  211. let a = Space_Object::Asteroid(Asteroid::Asteroid);
  212. let b = Space_Object::Asteroid(Asteroid::Exploding_Asteroid);
  213. collide(a, b);
  214. }
  215.  
  216. {
  217. let a = Space_Object::Asteroid(Asteroid::Exploding_Asteroid);
  218. let b = Space_Object::Spaceship(Spaceship::Spaceship);
  219. collide(a, b);
  220. }
  221.  
  222. {
  223. let a = Space_Object::Asteroid(Asteroid::Exploding_Asteroid);
  224. let b = Space_Object::Spaceship(Spaceship::Apollo_Spacecraft);
  225. collide(a, b);
  226. }
  227.  
  228. {
  229. let a = Space_Object::Asteroid(Asteroid::Exploding_Asteroid);
  230. let b = Space_Object::Asteroid(Asteroid::Asteroid);
  231. collide(a, b);
  232. }
  233.  
  234. {
  235. let a = Space_Object::Asteroid(Asteroid::Exploding_Asteroid);
  236. let b = Space_Object::Asteroid(Asteroid::Exploding_Asteroid);
  237. collide(a, b);
  238. }
  239. }
  240.  
  241. // =>
  242. // Spaceship hit Spaceship
  243. // Spaceship hit Apollo_Spacecraft
  244. // Spaceship hit Asteroid
  245. // Spaceship hit Exploding_Asteroid
  246. // Apollo_Spacecraft hit Spaceship
  247. // Apollo_Spacecraft hit Apollo_Spacecraft
  248. // Apollo_Spacecraft hit Asteroid
  249. // Apollo_Spacecraft hit Exploding_Asteroid
  250. // Asteroid hit Spaceship
  251. // Asteroid hit Apollo_Spacecraft
  252. // Asteroid hit Asteroid
  253. // Asteroid hit Exploding_Asteroid
  254. // Exploding_Asteroid hit Spaceship
  255. // Exploding_Asteroid hit Apollo_Spacecraft
  256. // Exploding_Asteroid hit Asteroid
  257. // Exploding_Asteroid hit Exploding_Asteroid
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement