Created
May 21, 2017 14:03
-
-
Save eyelash/133a11066e47cd4e4dca36e804943afd to your computer and use it in GitHub Desktop.
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
| fn get_longest(v: &[String]) -> &str { | |
| assert!(v.len() > 0); | |
| let mut result = &v[0]; | |
| for s in v { | |
| if s.len() > result.len() { | |
| result = &s | |
| } | |
| } | |
| result.as_str() | |
| } | |
| fn foo(v: &mut Vec<String>) { | |
| let longest = get_longest(v); | |
| if longest != "longest" { | |
| let longest = format!("{} (longest)", longest.len()); | |
| v.push(longest); | |
| } | |
| } | |
| fn main() { | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment