Logo

Programming-Idioms

History of Idiom 41 > diff from v66 to v67

Edit summary for version 67 by programming-idioms.org:
[Rust] +demo

Version 66

2019-12-08, 21:33:16

Version 67

2019-12-08, 21:35:45

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 t: String = s.chars().rev().collect();
Code
let t: String = s.chars().rev().collect();
Demo URL
https://play.rust-lang.org/?version=stable&mode=debug&edition=2015&gist=839f7495fb191691f7ed50a75f2ffd1e