Skip to content

Instantly share code, notes, and snippets.

@sassman
Last active September 8, 2019 22:26
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 sassman/8e36a3f45d12bcaa5d31d05aff97eb0d to your computer and use it in GitHub Desktop.
Save sassman/8e36a3f45d12bcaa5d31d05aff97eb0d to your computer and use it in GitHub Desktop.
rust tdd: src/lib.rs
// src/lib.rs
pub fn alphabet_position(s: &str) -> String {
s.to_lowercase() // <-- adding this line
.chars()
.map(|x| -> u8 { x as u8 - 'a' as u8 + 1 })
.map(|x| -> String { x.to_string() })
.collect::<Vec<String>>()
.join(" ")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment