Created
December 22, 2022 20:16
-
-
Save noemk2/d42563b23ce4fba7a0c94b61176ca429 to your computer and use it in GitHub Desktop.
pop in rust
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #![allow(unused)] | |
| fn main() { | |
| let rust = "Rust"; | |
| let popped = &rust[..rust.len() - 1]; | |
| println!("{}", popped); | |
| let poo = { | |
| let mut chars = rust.chars(); | |
| chars.next_back(); | |
| chars.as_str() | |
| }; | |
| assert_eq!(popped, "Rus"); | |
| assert_eq!(poo, "Rus"); | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment