Skip to content

Instantly share code, notes, and snippets.

@eddyb
Forked from Ms2ger/gist:83d07a3df86707245b4d
Last active August 29, 2015 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eddyb/81fb9edf198aceecb2f3 to your computer and use it in GitHub Desktop.
Save eddyb/81fb9edf198aceecb2f3 to your computer and use it in GitHub Desktop.
let mut result = "".into_string();
let mut chars = remainder.chars();
while let Some(c) = chars.next() {
if c == '-' {
match chars.next() {
Some(c @ 'a'...'z') => {
result.push(c.to_uppercase());
}
Some(c) => {
result.push('-');
result.push(c);
}
None => {
result.push('-');
break;
}
}
} else {
result.push(c);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment