Get length of longest String in a Vec in Rust
Category: rust, year: 2021
The following code snippet is an example of how to find out the length of the longest String in a Vec using Rust:
let string_vec = vec!["One", "Two", "Three", "Twenty"];
let max_string_length = string_vec.iter().map(|t| t.len()).max().unwrap();
eprintln!("Max string length: {}", max_string_length);