How to switch chars within a string in an idiomatic or efficient way?
⚓ Rust 📅 2025-05-23 👤 surdeus 👁️ 10Hello,
I am working through the Rust book and there is a small exercise:
Convert strings to pig latin. The first consonant of each word is moved to the end of the word and ay is added, so first becomes irst-fay . Words that start with a vowel have hay added to the end instead (apple becomes apple-hay ).
I can only solve this with complicated case distinctions and helper functions. Is there an elegant solution? Thanks!
3 posts - 3 participants
🏷️ rust_feed