Initial pig latin

This commit is contained in:
2020-11-24 11:26:39 +00:00
parent e1298507d3
commit 80a2eb72a8

28
src/pig_latin.rs Normal file
View File

@@ -0,0 +1,28 @@
// Take a &str
// - assume single words (check for no spaces)
// - convert to String
// pop the first
// append ay
// move to end
// Handle sentences: take a &str, convert to array, then do the above for each and return
// a new array
// https://scottwlaforest.com/rust/the-rust-book-chapter-8-exercises/
// NOTE: Check for vowels!
fn pig_latin(string: &str) -> String {
let s = String::from(string);
println!("{:?}", s.chars());
s
}
#[cfg(test)]
mod test {
use super::*;
#[test]
fn test_pig_latin() {
let string = "rust❤";
let result = pig_latin(string);
println!("{}", result);
}
}