Reversing a string in Rust (for no reason) (video.infosec.exchange)
from mesamunefire@piefed.social to programming@programming.dev on 18 Nov 16:44
https://piefed.social/c/programming/p/1488033/reversing-a-string-in-rust-for-no-reason

Feeling slightly exhausted by the world? Let’s reverse a string in Rust in a needlessly complicated way. I was expecting to make a tiny simple video and ended up going further into unsafe than I ev…

#programming

threaded - newest

BB_C@programming.dev on 18 Nov 17:30 collapse

I gave this a quick look at 2X speed with a lot fast seeking, and my brain still hurts.

First of all, and concerning Rust, please familiarize yourself with the mem module and its functions at least. You didn’t even get near a situation where using unsafe{} was actually required.

Second of all, and concerning the task at hand itself, for someone who knew to make the distinction between bytes and chars, you should have known about grapheme clusters too. There are a lot of multi-char (not just multi-byte) graphemes out there. You can make a “Fun With Flags” 😉 segment to show that off (no attribution required). Just don’t do anything silly, and make sure to just utilize the unicode-segmentation crate.

hades@programming.dev on 19 Nov 06:38 collapse

Thank you for watching the video and answering the question that I had from just reading the title.

Reversing a UTF-8 string is super hard in any language, rust doesn’t really make it that much harder.