Ad
  • Custom User Avatar

    The Rust translation needs some work.

    • Tests should be in a tests module with #[cfg(test)]
    • &[_] is more idiomatic and flexible and should always be preferred over &Vec<_>
    • -> () return type is moot and discouraged.
    • The spacing should be inline with rustfmt, which leaves an empty line between functions, and spaces lists as [a, b, c] instead of [ a,b,c ].
    • The todo!() macro is a more idiomatic way to mark unwritten code, rather than a comment that fails compilation.
    • The type for a function that takes 2 i64s and returns 1 is fn(i64, i64) -> i64. The user shouldn't have to write their own function signatures.
    • The reference solution is needlessly complex.
  • Custom User Avatar
  • Custom User Avatar

    You apparently need to merge the current description into this fork. Otherwise, I can't approve it.

    Description cannot be approved, recent changes from related record must be merged first.

  • Custom User Avatar

    Rust tests are run in parallel with nondeterministic ordering, though with only two of them it would be easier enough to submit until such a solution passed. Added random tests.

  • Custom User Avatar

    Random tests just need to ensure that you can't hardcode the solution based on the order of tests.
    A function that returns 52 times true followed by 43 times false would be able to pass the fixed tests.

    See https://docs.codewars.com/authoring/guidelines/submission-tests/#random-tests

  • Custom User Avatar

    I've improved the non-sample assertion messages.

    Random tests don't do anything if the test coverage is exhaustive. Though I might have missed some characters, so please let me know. I'm assuming only ascii printable characters are included.

  • Custom User Avatar

    Could you add some random tests and assertion messages?

    The messages for the sample tests are probably fine, but the others just say assertion failed: is_it_letter(c).
    You could do it like this: assert!(is_it_letter(c), "is_it_letter('{}') wasn't true", c);.

  • Custom User Avatar

    Good work!

    A few notes if you're interested (ignore if not):

    • unit () return type is typically omitted
    • random tests don't do much when you're testing the same function on the left and right side
    • the later arguments in assert_eq! are already equivalent to format!

    Forked with these changes and a few more. Feel free to ask me if you have any questions.

  • Custom User Avatar

    I had no idea. Thanks for letting me know.

  • Custom User Avatar

    Also made a typo trying to type "typo".

  • Custom User Avatar

    Thanks for updating stale translations. I've approved a downstream fork.

    For future reference: unless the reference solution is wrong/buggy or not performant enough, there's no reason to change it with your own in a fork; when the translation is approved, the solution (with your changes!) will show up under the original author's name, not yours. I'm sure you'll understand why it's undesirable to publish code in someone else's name.

  • Custom User Avatar

    Fixed type in assertions.

  • Custom User Avatar

    More precisely used array of length 5 instead of slice, improved the error meesage, and general formatting improvements.

  • Custom User Avatar

    My only uncertainty is whether, when showing assertion failures, it's better to print

    C|\n|o\nd|\n|e\nw|\n|a\nr|\ns|
    

    or

    C|
    |o
    d|
    |e
    w|
    |a
    r|
    s|
    

    I currently do the former.

  • Default User Avatar

    Yeah, probably. I remember wondering about that when I wrote it. Then the tests all came back green and I forgot about it and moved on.

  • Loading more items...