Created
April 23, 2021 02:35
-
-
Save git314/252965a918d33a154543f9759b7f6c36 to your computer and use it in GitHub Desktop.
This file contains 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
fn main() { | |
let s = "...".to_string(); | |
let a = vec!["abc","abcde","abcdefgh","abcdefghijkl","abcdefghijklmnop"] | |
.into_iter() | |
.map(String::from) | |
.map(|mut string| | |
if string.len() > 5 { string.truncate(5); [string, s.to_string()].join("") } | |
else {string.truncate(5); string}) | |
.collect::<Vec<String>>(); | |
println!("{:?}",a) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment