Ad
  • Default User Avatar

    Very idiomatic... I like it!

  • Default User Avatar

    The code is short, very slick, but all those strings!

  • Default User Avatar

    That's very nice... I did the same logic but missed the application of fold, which is elegant.

  • Default User Avatar

    A very elegant solution if I may say so, distinguishing the square that may arise in processing from a square supplied as initall argument.

  • Default User Avatar

    In Rust, types str and String are Unicode strings, with varialbe sized chars, so you can't index into them or easily determine their length in chars or graphemes. The len() method is the length in bytes. The only way to reliably process a Unicode string is to iterate from the start. All the solutions to this in Rust which make use of len() are vulnerable to Unicode strings with multibyte chars.

  • Custom User Avatar

    This is just an old answer, so its had a long time to slowly accumulate votes. There's no generic upvote, you either vote for best practice or clever, and this is definitely NOT clever.

    It's also rust, which very few people truly understand (certainly including me) so many people don't know what they're looking at.

    That being said, I haven't ever used C and C++ only like 15 years ago, so this is more just general procedural language not really C/C++. But yeah, there are definitely more concise ways of doing this in rust, considering it's awesome methods on iterables.

  • Default User Avatar

    Several upticks for 'Best Practices' which I don't understand. This is exactly a C/C++ solution transscribed into Rust, it works but is not idiomatic Rust. I'd therefore say NOT best practice.