Logo

Programming-Idioms

History of Idiom 41 > diff from v39 to v40

Edit summary for version 40 by programming-idioms.org:
[Rust] No sample value inside the snippet
↷

Version 39

2018-01-03, 23:44:30

Version 40

2018-01-03, 23:59:44

Idiom #41 Reverse a string

Create string t containing the same characters as string s, in reverse order.
Original string s must remain unaltered. Each character must be handled correctly regardless its number of bytes in memory.

Illustration

Idiom #41 Reverse a string

Create string t containing the same characters as string s, in reverse order.
Original string s must remain unaltered. Each character must be handled correctly regardless its number of bytes in memory.

Illustration
Code
let s = "lorém ipsüm dolör sit amor ❤ ";
let t = s.chars().rev().collect::<String>();
Code
let t = s.chars().rev().collect::<String>();
Demo URL
https://is.gd/Jztpr6
Demo URL
https://is.gd/Jztpr6