How to switch chars within a string in an idiomatic or efficient way?

⚓ rust    📅 2025-05-23    👤 surdeus    👁️ 4      

surdeus

Warning

This post was published 37 days ago. The information described in this article may have changed.

Hello,

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

Read full topic

🏷️ rust_feed