trackler 2.2.1.128 → 2.2.1.129

Sign up to get free protection for your applications and to get access to all the features.
Files changed (308) hide show
  1. checksums.yaml +4 -4
  2. data/lib/trackler/version.rb +1 -1
  3. data/problem-specifications/exercises/bracket-push/canonical-data.json +9 -1
  4. data/tracks/bash/config.json +3 -3
  5. data/tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon +3 -1
  6. data/tracks/crystal/exercises/difference-of-squares/spec/difference_of_squares_spec.cr +9 -9
  7. data/tracks/csharp/config.json +12 -0
  8. data/tracks/csharp/exercises/Exercises.sln +7 -1
  9. data/tracks/csharp/exercises/yacht/Example.cs +71 -0
  10. data/tracks/csharp/exercises/yacht/README.md +34 -0
  11. data/tracks/csharp/exercises/yacht/Yacht.cs +26 -0
  12. data/tracks/csharp/exercises/yacht/Yacht.csproj +18 -0
  13. data/tracks/csharp/exercises/yacht/YachtTest.cs +162 -0
  14. data/tracks/csharp/generators/Exercises/Yacht.cs +20 -0
  15. data/tracks/dart/exercises/leap/lib/example.dart +4 -8
  16. data/tracks/dart/exercises/leap/lib/leap.dart +1 -1
  17. data/tracks/dart/exercises/leap/test/leap_test.dart +14 -16
  18. data/tracks/delphi/config.json +11 -0
  19. data/tracks/delphi/exercises/bracket-push/BracketPush.dpr +60 -0
  20. data/tracks/delphi/exercises/bracket-push/README.md +31 -0
  21. data/tracks/delphi/exercises/bracket-push/uBracketPushExample.pas +40 -0
  22. data/tracks/delphi/exercises/bracket-push/uBracketPushTest.pas +158 -0
  23. data/tracks/fsharp/config.json +18 -6
  24. data/tracks/fsharp/exercises/Exercises.sln +7 -1
  25. data/tracks/fsharp/exercises/accumulate/Accumulate.fsproj +2 -2
  26. data/tracks/fsharp/exercises/acronym/Acronym.fsproj +2 -2
  27. data/tracks/fsharp/exercises/all-your-base/AllYourBase.fsproj +2 -2
  28. data/tracks/fsharp/exercises/allergies/Allergies.fsproj +2 -2
  29. data/tracks/fsharp/exercises/alphametics/Alphametics.fsproj +2 -2
  30. data/tracks/fsharp/exercises/anagram/Anagram.fsproj +2 -2
  31. data/tracks/fsharp/exercises/armstrong-numbers/ArmstrongNumbers.fsproj +2 -2
  32. data/tracks/fsharp/exercises/atbash-cipher/AtbashCipher.fsproj +2 -2
  33. data/tracks/fsharp/exercises/bank-account/BankAccount.fsproj +2 -2
  34. data/tracks/fsharp/exercises/beer-song/BeerSong.fsproj +2 -2
  35. data/tracks/fsharp/exercises/binary/Binary.fsproj +2 -2
  36. data/tracks/fsharp/exercises/binary-search/BinarySearch.fsproj +2 -2
  37. data/tracks/fsharp/exercises/binary-search-tree/BinarySearchTree.fsproj +2 -2
  38. data/tracks/fsharp/exercises/bob/Bob.fsproj +2 -2
  39. data/tracks/fsharp/exercises/book-store/BookStore.fsproj +2 -2
  40. data/tracks/fsharp/exercises/bowling/Bowling.fsproj +2 -2
  41. data/tracks/fsharp/exercises/bowling/BowlingTest.fs +15 -1
  42. data/tracks/fsharp/exercises/bracket-push/BracketPush.fsproj +2 -2
  43. data/tracks/fsharp/exercises/change/Change.fsproj +2 -2
  44. data/tracks/fsharp/exercises/circular-buffer/CircularBuffer.fsproj +2 -2
  45. data/tracks/fsharp/exercises/circular-buffer/CircularBufferTest.fs +1 -1
  46. data/tracks/fsharp/exercises/clock/Clock.fsproj +2 -2
  47. data/tracks/fsharp/exercises/collatz-conjecture/CollatzConjecture.fsproj +2 -2
  48. data/tracks/fsharp/exercises/complex-numbers/ComplexNumbers.fsproj +2 -2
  49. data/tracks/fsharp/exercises/connect/Connect.fsproj +2 -2
  50. data/tracks/fsharp/exercises/crypto-square/CryptoSquare.fsproj +2 -2
  51. data/tracks/fsharp/exercises/custom-set/CustomSet.fsproj +2 -2
  52. data/tracks/fsharp/exercises/diamond/Diamond.fsproj +2 -2
  53. data/tracks/fsharp/exercises/difference-of-squares/DifferenceOfSquares.fsproj +2 -2
  54. data/tracks/fsharp/exercises/diffie-hellman/DiffieHellman.fsproj +2 -2
  55. data/tracks/fsharp/exercises/dominoes/Dominoes.fsproj +2 -2
  56. data/tracks/fsharp/exercises/dot-dsl/DotDsl.fsproj +2 -2
  57. data/tracks/fsharp/exercises/error-handling/ErrorHandling.fsproj +2 -2
  58. data/tracks/fsharp/exercises/etl/Etl.fsproj +2 -2
  59. data/tracks/fsharp/exercises/food-chain/FoodChain.fsproj +2 -2
  60. data/tracks/fsharp/exercises/forth/Forth.fsproj +2 -2
  61. data/tracks/fsharp/exercises/forth/ForthTest.fs +1 -1
  62. data/tracks/fsharp/exercises/gigasecond/Gigasecond.fsproj +2 -2
  63. data/tracks/fsharp/exercises/go-counting/GoCounting.fsproj +2 -2
  64. data/tracks/fsharp/exercises/grade-school/GradeSchool.fsproj +2 -2
  65. data/tracks/fsharp/exercises/grains/Grains.fsproj +2 -2
  66. data/tracks/fsharp/exercises/grains/GrainsTest.fs +1 -1
  67. data/tracks/fsharp/exercises/grep/Grep.fsproj +2 -2
  68. data/tracks/fsharp/exercises/grep/GrepTest.fs +1 -1
  69. data/tracks/fsharp/exercises/hamming/Hamming.fsproj +2 -2
  70. data/tracks/fsharp/exercises/hangman/Hangman.fsproj +2 -2
  71. data/tracks/fsharp/exercises/hello-world/HelloWorld.fsproj +2 -2
  72. data/tracks/fsharp/exercises/hexadecimal/Hexadecimal.fsproj +2 -2
  73. data/tracks/fsharp/exercises/house/Example.fs +2 -2
  74. data/tracks/fsharp/exercises/house/House.fsproj +2 -2
  75. data/tracks/fsharp/exercises/house/HouseTest.fs +28 -211
  76. data/tracks/fsharp/exercises/isbn-verifier/IsbnVerifier.fsproj +2 -2
  77. data/tracks/fsharp/exercises/isbn-verifier/IsbnVerifierTest.fs +2 -2
  78. data/tracks/fsharp/exercises/isogram/Isogram.fsproj +2 -2
  79. data/tracks/fsharp/exercises/isogram/IsogramTest.fs +1 -1
  80. data/tracks/fsharp/exercises/kindergarten-garden/KindergartenGarden.fsproj +2 -2
  81. data/tracks/fsharp/exercises/largest-series-product/LargestSeriesProduct.fsproj +2 -2
  82. data/tracks/fsharp/exercises/leap/Leap.fsproj +2 -2
  83. data/tracks/fsharp/exercises/ledger/Ledger.fsproj +2 -2
  84. data/tracks/fsharp/exercises/lens-person/LensPerson.fsproj +2 -2
  85. data/tracks/fsharp/exercises/linked-list/LinkedList.fsproj +2 -2
  86. data/tracks/fsharp/exercises/list-ops/ListOps.fsproj +2 -2
  87. data/tracks/fsharp/exercises/list-ops/ListOpsTest.fs +1 -1
  88. data/tracks/fsharp/exercises/luhn/Luhn.fsproj +2 -2
  89. data/tracks/fsharp/exercises/markdown/Markdown.fsproj +2 -2
  90. data/tracks/fsharp/exercises/matrix/Matrix.fsproj +2 -2
  91. data/tracks/fsharp/exercises/meetup/Meetup.fsproj +2 -2
  92. data/tracks/fsharp/exercises/minesweeper/Minesweeper.fsproj +2 -2
  93. data/tracks/fsharp/exercises/nth-prime/NthPrime.fsproj +2 -2
  94. data/tracks/fsharp/exercises/nucleotide-count/NucleotideCount.fsproj +2 -2
  95. data/tracks/fsharp/exercises/ocr-numbers/OcrNumbers.fsproj +2 -2
  96. data/tracks/fsharp/exercises/octal/Octal.fsproj +2 -2
  97. data/tracks/fsharp/exercises/palindrome-products/PalindromeProducts.fsproj +2 -2
  98. data/tracks/fsharp/exercises/pangram/Pangram.fsproj +2 -2
  99. data/tracks/fsharp/exercises/parallel-letter-frequency/ParallelLetterFrequency.fsproj +2 -2
  100. data/tracks/fsharp/exercises/pascals-triangle/PascalsTriangle.fsproj +2 -2
  101. data/tracks/fsharp/exercises/perfect-numbers/PerfectNumbers.fsproj +2 -2
  102. data/tracks/fsharp/exercises/phone-number/PhoneNumber.fsproj +2 -2
  103. data/tracks/fsharp/exercises/pig-latin/PigLatin.fsproj +2 -2
  104. data/tracks/fsharp/exercises/poker/Poker.fsproj +2 -2
  105. data/tracks/fsharp/exercises/pov/Pov.fsproj +2 -2
  106. data/tracks/fsharp/exercises/pov/PovTest.fs +2 -2
  107. data/tracks/fsharp/exercises/prime-factors/PrimeFactors.fsproj +2 -2
  108. data/tracks/fsharp/exercises/protein-translation/ProteinTranslation.fsproj +2 -2
  109. data/tracks/fsharp/exercises/proverb/Proverb.fsproj +2 -2
  110. data/tracks/fsharp/exercises/pythagorean-triplet/PythagoreanTriplet.fsproj +2 -2
  111. data/tracks/fsharp/exercises/queen-attack/QueenAttack.fsproj +2 -2
  112. data/tracks/fsharp/exercises/rail-fence-cipher/RailFenceCipher.fsproj +2 -2
  113. data/tracks/fsharp/exercises/raindrops/Raindrops.fsproj +2 -2
  114. data/tracks/fsharp/exercises/rational-numbers/RationalNumbers.fsproj +2 -2
  115. data/tracks/fsharp/exercises/react/Example.fs +1 -1
  116. data/tracks/fsharp/exercises/react/React.fsproj +2 -2
  117. data/tracks/fsharp/exercises/react/ReactTest.fs +14 -1
  118. data/tracks/fsharp/exercises/rectangles/Rectangles.fsproj +2 -2
  119. data/tracks/fsharp/exercises/reverse-string/ReverseString.fsproj +2 -2
  120. data/tracks/fsharp/exercises/rna-transcription/RnaTranscription.fsproj +2 -2
  121. data/tracks/fsharp/exercises/robot-name/RobotName.fsproj +2 -2
  122. data/tracks/fsharp/exercises/robot-simulator/RobotSimulator.fsproj +2 -2
  123. data/tracks/fsharp/exercises/roman-numerals/RomanNumerals.fsproj +2 -2
  124. data/tracks/fsharp/exercises/rotational-cipher/RotationalCipher.fsproj +2 -2
  125. data/tracks/fsharp/exercises/run-length-encoding/RunLengthEncoding.fsproj +2 -2
  126. data/tracks/fsharp/exercises/saddle-points/SaddlePoints.fsproj +2 -2
  127. data/tracks/fsharp/exercises/say/Say.fsproj +2 -2
  128. data/tracks/fsharp/exercises/scale-generator/ScaleGenerator.fsproj +2 -2
  129. data/tracks/fsharp/exercises/scrabble-score/ScrabbleScore.fsproj +2 -2
  130. data/tracks/fsharp/exercises/secret-handshake/SecretHandshake.fsproj +2 -2
  131. data/tracks/fsharp/exercises/series/Series.fsproj +2 -2
  132. data/tracks/fsharp/exercises/sgf-parsing/SgfParsing.fsproj +2 -2
  133. data/tracks/fsharp/exercises/sieve/Sieve.fsproj +2 -2
  134. data/tracks/fsharp/exercises/simple-cipher/SimpleCipher.fsproj +2 -2
  135. data/tracks/fsharp/exercises/simple-linked-list/SimpleLinkedList.fsproj +2 -2
  136. data/tracks/fsharp/exercises/space-age/SpaceAge.fsproj +2 -2
  137. data/tracks/fsharp/exercises/spiral-matrix/SpiralMatrix.fsproj +2 -2
  138. data/tracks/fsharp/exercises/strain/Strain.fsproj +2 -2
  139. data/tracks/fsharp/exercises/sublist/Sublist.fsproj +2 -2
  140. data/tracks/fsharp/exercises/sum-of-multiples/SumOfMultiples.fsproj +2 -2
  141. data/tracks/fsharp/exercises/tournament/Tournament.fsproj +2 -2
  142. data/tracks/fsharp/exercises/transpose/Transpose.fsproj +2 -2
  143. data/tracks/fsharp/exercises/tree-building/TreeBuilding.fsproj +2 -2
  144. data/tracks/fsharp/exercises/triangle/Triangle.fsproj +2 -2
  145. data/tracks/fsharp/exercises/trinary/Trinary.fsproj +2 -2
  146. data/tracks/fsharp/exercises/twelve-days/TwelveDays.fsproj +2 -2
  147. data/tracks/fsharp/exercises/two-bucket/TwoBucket.fsproj +2 -2
  148. data/tracks/fsharp/exercises/two-fer/TwoFer.fsproj +2 -2
  149. data/tracks/fsharp/exercises/variable-length-quantity/VariableLengthQuantity.fsproj +2 -2
  150. data/tracks/fsharp/exercises/word-count/WordCount.fsproj +2 -2
  151. data/tracks/fsharp/exercises/word-search/WordSearch.fsproj +2 -2
  152. data/tracks/fsharp/exercises/word-search/WordSearchTest.fs +1 -1
  153. data/tracks/fsharp/exercises/wordy/Wordy.fsproj +2 -2
  154. data/tracks/fsharp/exercises/yacht/Example.fs +65 -0
  155. data/tracks/fsharp/exercises/yacht/Program.fs +1 -0
  156. data/tracks/fsharp/exercises/yacht/README.md +34 -0
  157. data/tracks/fsharp/exercises/yacht/Yacht.fs +17 -0
  158. data/tracks/fsharp/exercises/yacht/Yacht.fsproj +23 -0
  159. data/tracks/fsharp/exercises/yacht/YachtTest.fs +113 -0
  160. data/tracks/fsharp/exercises/zebra-puzzle/ZebraPuzzle.fsproj +2 -2
  161. data/tracks/fsharp/exercises/zipper/Zipper.fsproj +2 -2
  162. data/tracks/fsharp/generators/CanonicalData.fs +2 -20
  163. data/tracks/fsharp/generators/Common.fs +1 -1
  164. data/tracks/fsharp/generators/Generators.fs +24 -11
  165. data/tracks/fsharp/generators/Generators.fsproj +4 -4
  166. data/tracks/fsharp/generators/Options.fs +1 -1
  167. data/tracks/haskell/exercises/bracket-push/package.yaml +1 -1
  168. data/tracks/haskell/exercises/bracket-push/test/Tests.hs +4 -0
  169. data/tracks/java/config.json +13 -0
  170. data/tracks/java/exercises/dominoes/.meta/src/reference/java/ChainNotFoundException.java +5 -0
  171. data/tracks/java/exercises/dominoes/.meta/src/reference/java/Domino.java +30 -0
  172. data/tracks/java/exercises/dominoes/.meta/src/reference/java/Dominoes.java +67 -0
  173. data/tracks/java/exercises/dominoes/.meta/version +2 -0
  174. data/tracks/java/exercises/dominoes/README.md +29 -0
  175. data/tracks/java/exercises/dominoes/build.gradle +18 -0
  176. data/tracks/java/exercises/dominoes/src/main/java/ChainNotFoundException.java +5 -0
  177. data/tracks/java/exercises/dominoes/src/main/java/Domino.java +30 -0
  178. data/tracks/java/exercises/dominoes/src/test/java/DominoesTest.java +230 -0
  179. data/tracks/java/exercises/settings.gradle +1 -0
  180. data/tracks/javascript/.eslintignore +0 -1
  181. data/tracks/javascript/exercises/simple-cipher/example.js +4 -6
  182. data/tracks/javascript/exercises/simple-cipher/simple-cipher.spec.js +7 -3
  183. data/tracks/php/config.json +7 -7
  184. data/tracks/python/config.json +195 -188
  185. data/tracks/python/exercises/alphametics/alphametics_test.py +1 -0
  186. data/tracks/python/exercises/bank-account/README.md +20 -1
  187. data/tracks/python/exercises/go-counting/README.md +2 -0
  188. data/tracks/python/test/check-exercises.py +1 -1
  189. data/tracks/rust/_test/ensure-stubs-compile.sh +5 -0
  190. data/tracks/rust/config/exercise_readme.go.tmpl +1 -1
  191. data/tracks/rust/config.json +10 -0
  192. data/tracks/rust/exercises/accumulate/README.md +1 -1
  193. data/tracks/rust/exercises/acronym/README.md +1 -1
  194. data/tracks/rust/exercises/all-your-base/README.md +1 -1
  195. data/tracks/rust/exercises/all-your-base/example.rs +15 -5
  196. data/tracks/rust/exercises/all-your-base/src/lib.rs +8 -1
  197. data/tracks/rust/exercises/all-your-base/tests/all-your-base.rs +10 -5
  198. data/tracks/rust/exercises/allergies/README.md +1 -1
  199. data/tracks/rust/exercises/alphametics/README.md +1 -1
  200. data/tracks/rust/exercises/anagram/README.md +1 -1
  201. data/tracks/rust/exercises/armstrong-numbers/.gitignore +3 -0
  202. data/tracks/rust/exercises/armstrong-numbers/Cargo.toml +3 -0
  203. data/tracks/rust/exercises/armstrong-numbers/README.md +51 -0
  204. data/tracks/rust/exercises/armstrong-numbers/example.rs +7 -0
  205. data/tracks/rust/exercises/armstrong-numbers/src/lib.rs +3 -0
  206. data/tracks/rust/exercises/armstrong-numbers/tests/armstrong-numbers.rs +49 -0
  207. data/tracks/rust/exercises/atbash-cipher/README.md +1 -1
  208. data/tracks/rust/exercises/beer-song/README.md +1 -1
  209. data/tracks/rust/exercises/binary-search/README.md +1 -1
  210. data/tracks/rust/exercises/bob/README.md +1 -1
  211. data/tracks/rust/exercises/book-store/README.md +1 -1
  212. data/tracks/rust/exercises/bowling/README.md +1 -1
  213. data/tracks/rust/exercises/bowling/example.rs +13 -8
  214. data/tracks/rust/exercises/bowling/src/lib.rs +22 -0
  215. data/tracks/rust/exercises/bowling/tests/bowling.rs +31 -31
  216. data/tracks/rust/exercises/bracket-push/README.md +1 -1
  217. data/tracks/rust/exercises/circular-buffer/README.md +1 -1
  218. data/tracks/rust/exercises/clock/README.md +1 -1
  219. data/tracks/rust/exercises/collatz-conjecture/README.md +1 -1
  220. data/tracks/rust/exercises/crypto-square/README.md +1 -1
  221. data/tracks/rust/exercises/crypto-square/example.rs +11 -3
  222. data/tracks/rust/exercises/crypto-square/tests/crypto-square.rs +8 -16
  223. data/tracks/rust/exercises/custom-set/README.md +1 -1
  224. data/tracks/rust/exercises/custom-set/example.rs +17 -17
  225. data/tracks/rust/exercises/custom-set/tests/custom-set.rs +84 -84
  226. data/tracks/rust/exercises/decimal/README.md +1 -1
  227. data/tracks/rust/exercises/difference-of-squares/README.md +1 -1
  228. data/tracks/rust/exercises/diffie-hellman/README.md +1 -1
  229. data/tracks/rust/exercises/dominoes/README.md +1 -1
  230. data/tracks/rust/exercises/etl/README.md +1 -1
  231. data/tracks/rust/exercises/forth/README.md +1 -1
  232. data/tracks/rust/exercises/gigasecond/README.md +1 -1
  233. data/tracks/rust/exercises/grade-school/README.md +1 -1
  234. data/tracks/rust/exercises/grains/README.md +1 -1
  235. data/tracks/rust/exercises/hamming/README.md +1 -1
  236. data/tracks/rust/exercises/hello-world/README.md +1 -1
  237. data/tracks/rust/exercises/hexadecimal/README.md +1 -1
  238. data/tracks/rust/exercises/isbn-verifier/README.md +1 -1
  239. data/tracks/rust/exercises/isogram/README.md +1 -1
  240. data/tracks/rust/exercises/largest-series-product/README.md +1 -1
  241. data/tracks/rust/exercises/largest-series-product/example.rs +10 -4
  242. data/tracks/rust/exercises/largest-series-product/src/lib.rs +9 -0
  243. data/tracks/rust/exercises/largest-series-product/tests/largest-series-product.rs +3 -3
  244. data/tracks/rust/exercises/leap/README.md +1 -1
  245. data/tracks/rust/exercises/luhn/README.md +1 -1
  246. data/tracks/rust/exercises/luhn-from/README.md +1 -1
  247. data/tracks/rust/exercises/luhn-trait/README.md +1 -1
  248. data/tracks/rust/exercises/macros/.meta/ALLOWED_TO_NOT_COMPILE +2 -0
  249. data/tracks/rust/exercises/macros/README.md +1 -1
  250. data/tracks/rust/exercises/minesweeper/README.md +1 -1
  251. data/tracks/rust/exercises/nth-prime/README.md +1 -1
  252. data/tracks/rust/exercises/nucleotide-codons/README.md +1 -1
  253. data/tracks/rust/exercises/nucleotide-count/README.md +1 -1
  254. data/tracks/rust/exercises/ocr-numbers/README.md +1 -1
  255. data/tracks/rust/exercises/ocr-numbers/example.rs +14 -6
  256. data/tracks/rust/exercises/ocr-numbers/src/lib.rs +7 -1
  257. data/tracks/rust/exercises/ocr-numbers/tests/ocr-numbers.rs +2 -2
  258. data/tracks/rust/exercises/pangram/README.md +1 -1
  259. data/tracks/rust/exercises/parallel-letter-frequency/README.md +1 -1
  260. data/tracks/rust/exercises/pascals-triangle/README.md +1 -1
  261. data/tracks/rust/exercises/perfect-numbers/README.md +1 -1
  262. data/tracks/rust/exercises/phone-number/README.md +1 -1
  263. data/tracks/rust/exercises/pig-latin/README.md +1 -1
  264. data/tracks/rust/exercises/poker/README.md +1 -1
  265. data/tracks/rust/exercises/prime-factors/README.md +1 -1
  266. data/tracks/rust/exercises/protein-translation/README.md +1 -1
  267. data/tracks/rust/exercises/proverb/README.md +1 -1
  268. data/tracks/rust/exercises/pythagorean-triplet/README.md +1 -1
  269. data/tracks/rust/exercises/queen-attack/README.md +1 -1
  270. data/tracks/rust/exercises/raindrops/README.md +1 -1
  271. data/tracks/rust/exercises/react/README.md +1 -1
  272. data/tracks/rust/exercises/react/example.rs +27 -18
  273. data/tracks/rust/exercises/react/src/lib.rs +25 -10
  274. data/tracks/rust/exercises/react/tests/react.rs +113 -83
  275. data/tracks/rust/exercises/rectangles/README.md +1 -1
  276. data/tracks/rust/exercises/reverse-string/README.md +1 -1
  277. data/tracks/rust/exercises/rna-transcription/README.md +1 -1
  278. data/tracks/rust/exercises/robot-name/README.md +1 -1
  279. data/tracks/rust/exercises/robot-simulator/README.md +1 -1
  280. data/tracks/rust/exercises/roman-numerals/README.md +1 -1
  281. data/tracks/rust/exercises/rotational-cipher/README.md +1 -1
  282. data/tracks/rust/exercises/run-length-encoding/README.md +1 -1
  283. data/tracks/rust/exercises/saddle-points/README.md +1 -1
  284. data/tracks/rust/exercises/say/README.md +1 -1
  285. data/tracks/rust/exercises/scrabble-score/README.md +1 -1
  286. data/tracks/rust/exercises/series/README.md +1 -1
  287. data/tracks/rust/exercises/sieve/README.md +1 -1
  288. data/tracks/rust/exercises/simple-linked-list/README.md +1 -1
  289. data/tracks/rust/exercises/space-age/README.md +1 -1
  290. data/tracks/rust/exercises/sublist/README.md +1 -1
  291. data/tracks/rust/exercises/sum-of-multiples/README.md +1 -1
  292. data/tracks/rust/exercises/tournament/README.md +1 -1
  293. data/tracks/rust/exercises/triangle/README.md +1 -1
  294. data/tracks/rust/exercises/two-bucket/README.md +1 -1
  295. data/tracks/rust/exercises/variable-length-quantity/README.md +1 -1
  296. data/tracks/rust/exercises/word-count/README.md +1 -1
  297. data/tracks/rust/exercises/wordy/README.md +1 -1
  298. data/tracks/typescript/config.json +11 -0
  299. data/tracks/typescript/exercises/list-ops/README.md +35 -0
  300. data/tracks/typescript/exercises/list-ops/list-ops.example.ts +80 -0
  301. data/tracks/typescript/exercises/list-ops/list-ops.test.ts +117 -0
  302. data/tracks/typescript/exercises/list-ops/list-ops.ts +0 -0
  303. data/tracks/typescript/exercises/list-ops/package.json +36 -0
  304. data/tracks/typescript/exercises/list-ops/tsconfig.json +22 -0
  305. data/tracks/typescript/exercises/list-ops/tslint.json +127 -0
  306. data/tracks/typescript/exercises/list-ops/yarn.lock +2624 -0
  307. metadata +42 -3
  308. data/tracks/dart/exercises/leap/pubspec.lock +0 -293
@@ -42,7 +42,7 @@ haven't already, it will help you with organizing your files.
42
42
 
43
43
  ## Feedback, Issues, Pull Requests
44
44
 
45
- The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the [rust track team](https://github.com/orgs/exercism/teams/rust) are happy to help!
45
+ The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help!
46
46
 
47
47
  If you want to know more about Exercism, take a look at the [contribution guide](https://github.com/exercism/docs/blob/master/contributing-to-language-tracks/README.md).
48
48
 
@@ -0,0 +1,2 @@
1
+ Stub doesn't compile because there is no rule for the macro forms in the test file.
2
+ Providing these rules would reduce student learning, so we do not.
@@ -54,7 +54,7 @@ haven't already, it will help you with organizing your files.
54
54
 
55
55
  ## Feedback, Issues, Pull Requests
56
56
 
57
- The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the [rust track team](https://github.com/orgs/exercism/teams/rust) are happy to help!
57
+ The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help!
58
58
 
59
59
  If you want to know more about Exercism, take a look at the [contribution guide](https://github.com/exercism/docs/blob/master/contributing-to-language-tracks/README.md).
60
60
 
@@ -50,7 +50,7 @@ haven't already, it will help you with organizing your files.
50
50
 
51
51
  ## Feedback, Issues, Pull Requests
52
52
 
53
- The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the [rust track team](https://github.com/orgs/exercism/teams/rust) are happy to help!
53
+ The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help!
54
54
 
55
55
  If you want to know more about Exercism, take a look at the [contribution guide](https://github.com/exercism/docs/blob/master/contributing-to-language-tracks/README.md).
56
56
 
@@ -32,7 +32,7 @@ haven't already, it will help you with organizing your files.
32
32
 
33
33
  ## Feedback, Issues, Pull Requests
34
34
 
35
- The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the [rust track team](https://github.com/orgs/exercism/teams/rust) are happy to help!
35
+ The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help!
36
36
 
37
37
  If you want to know more about Exercism, take a look at the [contribution guide](https://github.com/exercism/docs/blob/master/contributing-to-language-tracks/README.md).
38
38
 
@@ -42,7 +42,7 @@ haven't already, it will help you with organizing your files.
42
42
 
43
43
  ## Feedback, Issues, Pull Requests
44
44
 
45
- The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the [rust track team](https://github.com/orgs/exercism/teams/rust) are happy to help!
45
+ The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help!
46
46
 
47
47
  If you want to know more about Exercism, take a look at the [contribution guide](https://github.com/exercism/docs/blob/master/contributing-to-language-tracks/README.md).
48
48
 
@@ -36,7 +36,7 @@ haven't already, it will help you with organizing your files.
36
36
 
37
37
  ## Feedback, Issues, Pull Requests
38
38
 
39
- The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the [rust track team](https://github.com/orgs/exercism/teams/rust) are happy to help!
39
+ The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help!
40
40
 
41
41
  If you want to know more about Exercism, take a look at the [contribution guide](https://github.com/exercism/docs/blob/master/contributing-to-language-tracks/README.md).
42
42
 
@@ -102,7 +102,7 @@ haven't already, it will help you with organizing your files.
102
102
 
103
103
  ## Feedback, Issues, Pull Requests
104
104
 
105
- The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the [rust track team](https://github.com/orgs/exercism/teams/rust) are happy to help!
105
+ The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help!
106
106
 
107
107
  If you want to know more about Exercism, take a look at the [contribution guide](https://github.com/exercism/docs/blob/master/contributing-to-language-tracks/README.md).
108
108
 
@@ -1,13 +1,21 @@
1
1
  use std::collections::BTreeMap;
2
- use std::str::Lines;
3
2
 
4
- fn lines_valid(lines: &Lines) -> bool {
5
- lines.clone().count() % 4 == 0 && lines.clone().all(|line| line.chars().count() % 3 == 0)
3
+ #[derive(Debug, PartialEq)]
4
+ pub enum Error {
5
+ InvalidRowCount(usize),
6
+ InvalidColumnCount(usize),
6
7
  }
7
8
 
8
- pub fn convert(input: &str) -> Result<String, ()> {
9
- if !lines_valid(&input.lines()) {
10
- return Err(());
9
+ pub fn convert(input: &str) -> Result<String, Error> {
10
+ let line_count = input.lines().count();
11
+ if line_count % 4 != 0 {
12
+ return Err(Error::InvalidRowCount(line_count));
13
+ }
14
+ for line in input.lines() {
15
+ let char_count = line.chars().count();
16
+ if char_count % 3 != 0 {
17
+ return Err(Error::InvalidColumnCount(char_count));
18
+ }
11
19
  }
12
20
 
13
21
  let y = input.lines().collect::<Vec<_>>();
@@ -1,7 +1,13 @@
1
1
  // The code below is a stub. Just enough to satisfy the compiler.
2
2
  // In order to pass the tests you can add-to or change any of this code.
3
3
 
4
+ #[derive(Debug, PartialEq)]
5
+ pub enum Error {
6
+ InvalidRowCount(usize),
7
+ InvalidColumnCount(usize),
8
+ }
9
+
4
10
  #[allow(unused_variables)]
5
- pub fn convert(input: &str) -> Result<String, ()> {
11
+ pub fn convert(input: &str) -> Result<String, Error> {
6
12
  unimplemented!();
7
13
  }
@@ -7,7 +7,7 @@ fn input_with_lines_not_multiple_of_four_is_error() {
7
7
  "| |\n" +
8
8
  " ";
9
9
 
10
- assert!(ocr::convert(&input).is_err());
10
+ assert_eq!(Err(ocr::Error::InvalidRowCount(3)), ocr::convert(&input));
11
11
  }
12
12
 
13
13
  #[test]
@@ -19,7 +19,7 @@ fn input_with_columns_not_multiple_of_three_is_error() {
19
19
  " |\n" +
20
20
  " ";
21
21
 
22
- assert!(ocr::convert(&input).is_err());
22
+ assert_eq!(Err(ocr::Error::InvalidColumnCount(4)), ocr::convert(&input));
23
23
  }
24
24
 
25
25
 
@@ -32,7 +32,7 @@ haven't already, it will help you with organizing your files.
32
32
 
33
33
  ## Feedback, Issues, Pull Requests
34
34
 
35
- The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the [rust track team](https://github.com/orgs/exercism/teams/rust) are happy to help!
35
+ The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help!
36
36
 
37
37
  If you want to know more about Exercism, take a look at the [contribution guide](https://github.com/exercism/docs/blob/master/contributing-to-language-tracks/README.md).
38
38
 
@@ -65,7 +65,7 @@ haven't already, it will help you with organizing your files.
65
65
 
66
66
  ## Feedback, Issues, Pull Requests
67
67
 
68
- The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the [rust track team](https://github.com/orgs/exercism/teams/rust) are happy to help!
68
+ The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help!
69
69
 
70
70
  If you want to know more about Exercism, take a look at the [contribution guide](https://github.com/exercism/docs/blob/master/contributing-to-language-tracks/README.md).
71
71
 
@@ -38,7 +38,7 @@ haven't already, it will help you with organizing your files.
38
38
 
39
39
  ## Feedback, Issues, Pull Requests
40
40
 
41
- The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the [rust track team](https://github.com/orgs/exercism/teams/rust) are happy to help!
41
+ The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help!
42
42
 
43
43
  If you want to know more about Exercism, take a look at the [contribution guide](https://github.com/exercism/docs/blob/master/contributing-to-language-tracks/README.md).
44
44
 
@@ -41,7 +41,7 @@ haven't already, it will help you with organizing your files.
41
41
 
42
42
  ## Feedback, Issues, Pull Requests
43
43
 
44
- The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the [rust track team](https://github.com/orgs/exercism/teams/rust) are happy to help!
44
+ The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help!
45
45
 
46
46
  If you want to know more about Exercism, take a look at the [contribution guide](https://github.com/exercism/docs/blob/master/contributing-to-language-tracks/README.md).
47
47
 
@@ -52,7 +52,7 @@ haven't already, it will help you with organizing your files.
52
52
 
53
53
  ## Feedback, Issues, Pull Requests
54
54
 
55
- The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the [rust track team](https://github.com/orgs/exercism/teams/rust) are happy to help!
55
+ The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help!
56
56
 
57
57
  If you want to know more about Exercism, take a look at the [contribution guide](https://github.com/exercism/docs/blob/master/contributing-to-language-tracks/README.md).
58
58
 
@@ -41,7 +41,7 @@ haven't already, it will help you with organizing your files.
41
41
 
42
42
  ## Feedback, Issues, Pull Requests
43
43
 
44
- The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the [rust track team](https://github.com/orgs/exercism/teams/rust) are happy to help!
44
+ The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help!
45
45
 
46
46
  If you want to know more about Exercism, take a look at the [contribution guide](https://github.com/exercism/docs/blob/master/contributing-to-language-tracks/README.md).
47
47
 
@@ -39,7 +39,7 @@ haven't already, it will help you with organizing your files.
39
39
 
40
40
  ## Feedback, Issues, Pull Requests
41
41
 
42
- The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the [rust track team](https://github.com/orgs/exercism/teams/rust) are happy to help!
42
+ The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help!
43
43
 
44
44
  If you want to know more about Exercism, take a look at the [contribution guide](https://github.com/exercism/docs/blob/master/contributing-to-language-tracks/README.md).
45
45
 
@@ -53,7 +53,7 @@ haven't already, it will help you with organizing your files.
53
53
 
54
54
  ## Feedback, Issues, Pull Requests
55
55
 
56
- The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the [rust track team](https://github.com/orgs/exercism/teams/rust) are happy to help!
56
+ The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help!
57
57
 
58
58
  If you want to know more about Exercism, take a look at the [contribution guide](https://github.com/exercism/docs/blob/master/contributing-to-language-tracks/README.md).
59
59
 
@@ -65,7 +65,7 @@ haven't already, it will help you with organizing your files.
65
65
 
66
66
  ## Feedback, Issues, Pull Requests
67
67
 
68
- The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the [rust track team](https://github.com/orgs/exercism/teams/rust) are happy to help!
68
+ The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help!
69
69
 
70
70
  If you want to know more about Exercism, take a look at the [contribution guide](https://github.com/exercism/docs/blob/master/contributing-to-language-tracks/README.md).
71
71
 
@@ -40,7 +40,7 @@ haven't already, it will help you with organizing your files.
40
40
 
41
41
  ## Feedback, Issues, Pull Requests
42
42
 
43
- The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the [rust track team](https://github.com/orgs/exercism/teams/rust) are happy to help!
43
+ The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help!
44
44
 
45
45
  If you want to know more about Exercism, take a look at the [contribution guide](https://github.com/exercism/docs/blob/master/contributing-to-language-tracks/README.md).
46
46
 
@@ -41,7 +41,7 @@ haven't already, it will help you with organizing your files.
41
41
 
42
42
  ## Feedback, Issues, Pull Requests
43
43
 
44
- The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the [rust track team](https://github.com/orgs/exercism/teams/rust) are happy to help!
44
+ The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help!
45
45
 
46
46
  If you want to know more about Exercism, take a look at the [contribution guide](https://github.com/exercism/docs/blob/master/contributing-to-language-tracks/README.md).
47
47
 
@@ -50,7 +50,7 @@ haven't already, it will help you with organizing your files.
50
50
 
51
51
  ## Feedback, Issues, Pull Requests
52
52
 
53
- The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the [rust track team](https://github.com/orgs/exercism/teams/rust) are happy to help!
53
+ The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help!
54
54
 
55
55
  If you want to know more about Exercism, take a look at the [contribution guide](https://github.com/exercism/docs/blob/master/contributing-to-language-tracks/README.md).
56
56
 
@@ -41,7 +41,7 @@ haven't already, it will help you with organizing your files.
41
41
 
42
42
  ## Feedback, Issues, Pull Requests
43
43
 
44
- The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the [rust track team](https://github.com/orgs/exercism/teams/rust) are happy to help!
44
+ The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help!
45
45
 
46
46
  If you want to know more about Exercism, take a look at the [contribution guide](https://github.com/exercism/docs/blob/master/contributing-to-language-tracks/README.md).
47
47
 
@@ -39,7 +39,7 @@ haven't already, it will help you with organizing your files.
39
39
 
40
40
  ## Feedback, Issues, Pull Requests
41
41
 
42
- The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the [rust track team](https://github.com/orgs/exercism/teams/rust) are happy to help!
42
+ The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help!
43
43
 
44
44
  If you want to know more about Exercism, take a look at the [contribution guide](https://github.com/exercism/docs/blob/master/contributing-to-language-tracks/README.md).
45
45
 
@@ -3,6 +3,18 @@ use std::collections::HashMap;
3
3
  pub type CellID = usize;
4
4
  pub type CallbackID = usize;
5
5
 
6
+ #[derive(Debug, PartialEq)]
7
+ pub enum SetValueError {
8
+ NonexistentCell,
9
+ ComputeCell,
10
+ }
11
+
12
+ #[derive(Debug, PartialEq)]
13
+ pub enum RemoveCallbackError {
14
+ NonexistentCell,
15
+ NonexistentCallback,
16
+ }
17
+
6
18
  struct Cell<'a, T: Copy> {
7
19
  value: T,
8
20
  last_value: T,
@@ -46,11 +58,11 @@ impl <'a, T: Copy + PartialEq> Reactor<'a, T> {
46
58
  self.cells.len() - 1
47
59
  }
48
60
 
49
- pub fn create_compute<F: Fn(&[T]) -> T + 'a>(&mut self, dependencies: &[CellID], compute_func: F) -> Result<CellID, &'static str> {
61
+ pub fn create_compute<F: Fn(&[T]) -> T + 'a>(&mut self, dependencies: &[CellID], compute_func: F) -> Result<CellID, CellID> {
50
62
  // Check all dependencies' validity before modifying any of them,
51
63
  // so that we don't perform an incorrect partial write.
52
- if !dependencies.iter().all(|&id| id < self.cells.len()) {
53
- return Err("Nonexistent input");
64
+ if let Some(&invalid) = dependencies.iter().find(|&dep| *dep >= self.cells.len()) {
65
+ return Err(invalid);
54
66
  }
55
67
  let new_id = self.cells.len();
56
68
  for &id in dependencies {
@@ -66,16 +78,16 @@ impl <'a, T: Copy + PartialEq> Reactor<'a, T> {
66
78
  self.cells.get(id).map(|c| c.value)
67
79
  }
68
80
 
69
- pub fn set_value(&mut self, id: CellID, new_value: T) -> Result<(), &'static str> {
81
+ pub fn set_value(&mut self, id: CellID, new_value: T) -> Result<(), SetValueError> {
70
82
  match self.cells.get_mut(id) {
71
83
  Some(c) => match c.cell_type {
72
84
  CellType::Input => {
73
85
  c.value = new_value;
74
86
  Ok(c.dependents.clone())
75
87
  },
76
- CellType::Compute(_, _) => Err("Can't set compute cell value directly"),
88
+ CellType::Compute(_, _) => Err(SetValueError::ComputeCell),
77
89
  },
78
- None => Err("Can't set nonexistent cell"),
90
+ None => Err(SetValueError::NonexistentCell),
79
91
  }.map(|deps| {
80
92
  for &d in deps.iter() {
81
93
  self.update_dependent(d);
@@ -88,24 +100,21 @@ impl <'a, T: Copy + PartialEq> Reactor<'a, T> {
88
100
  })
89
101
  }
90
102
 
91
- pub fn add_callback<F: FnMut(T) -> () + 'a>(&mut self, id: CellID, callback: F) -> Result<CallbackID, &'static str> {
92
- match self.cells.get_mut(id) {
93
- Some(c) => {
94
- c.callbacks_issued += 1;
95
- c.callbacks.insert(c.callbacks_issued, Box::new(callback));
96
- Ok(c.callbacks_issued)
97
- },
98
- None => Err("Can't add callback to nonexistent cell"),
99
- }
103
+ pub fn add_callback<F: FnMut(T) -> () + 'a>(&mut self, id: CellID, callback: F) -> Option<CallbackID> {
104
+ self.cells.get_mut(id).map(|c| {
105
+ c.callbacks_issued += 1;
106
+ c.callbacks.insert(c.callbacks_issued, Box::new(callback));
107
+ c.callbacks_issued
108
+ })
100
109
  }
101
110
 
102
- pub fn remove_callback(&mut self, cell: CellID, callback: CallbackID) -> Result<(), &'static str> {
111
+ pub fn remove_callback(&mut self, cell: CellID, callback: CallbackID) -> Result<(), RemoveCallbackError> {
103
112
  match self.cells.get_mut(cell) {
104
113
  Some(c) => match c.callbacks.remove(&callback) {
105
114
  Some(_) => Ok(()),
106
- None => Err("Can't remove nonexistent callback"),
115
+ None => Err(RemoveCallbackError::NonexistentCallback),
107
116
  },
108
- None => Err("Can't remove callback from nonexistent cell"),
117
+ None => Err(RemoveCallbackError::NonexistentCell),
109
118
  }
110
119
  }
111
120
 
@@ -5,6 +5,18 @@
5
5
  pub type CellID = ();
6
6
  pub type CallbackID = ();
7
7
 
8
+ #[derive(Debug, PartialEq)]
9
+ pub enum SetValueError {
10
+ NonexistentCell,
11
+ ComputeCell,
12
+ }
13
+
14
+ #[derive(Debug, PartialEq)]
15
+ pub enum RemoveCallbackError {
16
+ NonexistentCell,
17
+ NonexistentCallback,
18
+ }
19
+
8
20
  pub struct Reactor<T> {
9
21
  // Just so that the compiler doesn't complain about an unused type parameter.
10
22
  // You probably want to delete this field.
@@ -28,12 +40,14 @@ impl <T: Copy + PartialEq> Reactor<T> {
28
40
  // You do not need to reject compute functions that expect more arguments than there are
29
41
  // dependencies (how would you check for this, anyway?).
30
42
  //
31
- // Return an Err (and you can change the error type) if any dependency doesn't exist.
43
+ // If any dependency doesn't exist, returns an Err with that nonexistent dependency.
44
+ // (If multiple dependencies do not exist, exactly which one is returned is not defined and
45
+ // will not be tested)
32
46
  //
33
47
  // Notice that there is no way to *remove* a cell.
34
48
  // This means that you may assume, without checking, that if the dependencies exist at creation
35
49
  // time they will continue to exist as long as the Reactor exists.
36
- pub fn create_compute<F: Fn(&[T]) -> T>(&mut self, dependencies: &[CellID], compute_func: F) -> Result<CellID, ()> {
50
+ pub fn create_compute<F: Fn(&[T]) -> T>(&mut self, dependencies: &[CellID], compute_func: F) -> Result<CellID, CellID> {
37
51
  unimplemented!()
38
52
  }
39
53
 
@@ -50,20 +64,22 @@ impl <T: Copy + PartialEq> Reactor<T> {
50
64
 
51
65
  // Sets the value of the specified input cell.
52
66
  //
53
- // Return an Err (and you can change the error type) if the cell does not exist, or the
54
- // specified cell is a compute cell, since compute cells cannot have their values directly set.
67
+ // Returns an Err if either:
68
+ // * the cell does not exist
69
+ // * the specified cell is a compute cell, since compute cells cannot have their values
70
+ // directly set.
55
71
  //
56
72
  // Similarly, you may wonder about `get_mut(&mut self, id: CellID) -> Option<&mut Cell>`, with
57
73
  // a `set_value(&mut self, new_value: T)` method on `Cell`.
58
74
  //
59
75
  // As before, that turned out to add too much extra complexity.
60
- pub fn set_value(&mut self, id: CellID, new_value: T) -> Result<(), ()> {
76
+ pub fn set_value(&mut self, id: CellID, new_value: T) -> Result<(), SetValueError> {
61
77
  unimplemented!()
62
78
  }
63
79
 
64
80
  // Adds a callback to the specified compute cell.
65
81
  //
66
- // Return an Err (and you can change the error type) if the cell does not exist.
82
+ // Returns the ID of the just-added callback, or None if the cell doesn't exist.
67
83
  //
68
84
  // Callbacks on input cells will not be tested.
69
85
  //
@@ -73,17 +89,16 @@ impl <T: Copy + PartialEq> Reactor<T> {
73
89
  // * Exactly once if the compute cell's value changed as a result of the set_value call.
74
90
  // The value passed to the callback should be the final value of the compute cell after the
75
91
  // set_value call.
76
- pub fn add_callback<F: FnMut(T) -> ()>(&mut self, id: CellID, callback: F) -> Result<CallbackID, ()> {
92
+ pub fn add_callback<F: FnMut(T) -> ()>(&mut self, id: CellID, callback: F) -> Option<CallbackID> {
77
93
  unimplemented!()
78
94
  }
79
95
 
80
96
  // Removes the specified callback, using an ID returned from add_callback.
81
97
  //
82
- // Return an Err (and you can change the error type) if either the cell or callback
83
- // does not exist.
98
+ // Returns an Err if either the cell or callback does not exist.
84
99
  //
85
100
  // A removed callback should no longer be called.
86
- pub fn remove_callback(&mut self, cell: CellID, callback: CallbackID) -> Result<(), ()> {
101
+ pub fn remove_callback(&mut self, cell: CellID, callback: CallbackID) -> Result<(), RemoveCallbackError> {
87
102
  unimplemented!()
88
103
  }
89
104
  }