5 ms·
None of that matters with this code. There are no lifetimes here and in fact there is no ownership either. Everything is a primitive char. They’re always copie
by vips7L 2y ago
None of that matters with this code. There are no lifetimes here and in fact there is no ownership either. Everything is a primitive char. They’re always copied and no mutation occurs. It’s pure computation. You could write this code exactly the same way in those languages.
- dwattttt 2y agoTrue. You could write it in C or asm too, and it would be about as simple. But there's still a difference that if they weren't all primitive (and you can't always rely that they will be), you'll know it won't work straight away in Rust, whereas in the others you need to walk every data type involved to make sure ownership is clear (or rely on a garbage collector to save you).
- n_plus_1_acc 2y agoJava's HashMap for example is not thread-safe, but if you use it from multiple threads, you may or may not experience all kinds of issues.
- vips7L 2y agoAgain that only matters if there is mutation. Reads are perfectly safe to happen from any thread. This code is self contained. Rust isn’t a silver bullet here.