Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fn capitalize(s: &str) -> String {
- let mut c = s.chars();
- match c.next() {
- None => String::new(),
- Some(f) => f.to_uppercase().collect::<String>() + c.as_str(),
- }
- }
- fn main() {
- assert_eq!(capitalize("apple"), "Apple");
- assert_eq!(capitalize("banana"), "Banana");
- assert_eq!(capitalize("orange"), "Orange");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement