News for hackers. Stuff that matters.
Re:Thoughts on Rust, a few thousand lines in by burntsushi on Wednesday January 09, 2019 @08:15PM (#18870682)
I'm quite thankful that Rust has succinct notation for slicing strings. Do note that `string[n]` is not supported, so you'll stumble over an inconsistency in your mental model quite quickly if you think slicing is by codepoint.
Re:Thoughts on Rust, a few thousand lines in by int_19h on Wednesday January 09, 2019 @11:38PM (#18871565)
The lack of direct indexing is a good point. But strings aren't sliced on byte boundaries all that often either - it's far more common to use higher-level APIs like split(), that deal with offsets under the hood, so that sugar mostly ends up being used in the implementation of such APIs. And, really, would something like s.slice_u8(x, y) be that unwieldy over s[x..y]?