exercism: implement reverse(input: &str) -> String me: input.chars().rev().collect() things really do compose nicely, it's good
-
Show this thread
-
I'm interested in whether there's a "more efficient" way of doing this except reversing strings is a thing I have literally never done in production
3 replies 0 retweets 8 likesShow this thread -
Replying to @mountain_ghosts
It depends on what you mean by “character”. If it was ascii, then very yes. Graphemes cluster? Well that code is already wrong. Friggin strings
1 reply 0 retweets 3 likes -
Replying to @steveklabnik
I mean this is why you don't actually reverse a string I've never wanted to do that but if I did I'd reach for ICU
1 reply 0 retweets 4 likes -
Replying to @mountain_ghosts @steveklabnik
like, reversing "text" is extremely different from reversing "an array"
1 reply 0 retweets 3 likes -
Replying to @mountain_ghosts @steveklabnik
Just get an iterator over grapheme clusters and it's No Problem! https://crates.io/crates/unicode-segmentation …
1 reply 0 retweets 3 likes -
Still nope. The problem is that reversing a string is not an operation that makes general sense anyway. It's pretty anglocentric to ask this question.
2 replies 0 retweets 9 likes -
Replying to @ManishEarth @bodil and
Extended grapheme clusters approximate some things which may be useful here. But even then, the question is still incomplete/wrong.
1 reply 0 retweets 2 likes -
Replying to @ManishEarth @bodil and
It's fine as a programming exercise, but most pedagogical examples of string operations do not make sense. I really need to get around to writing "falsehoods programmers believe about strings"
1 reply 0 retweets 16 likes
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.