Files
chapter-8-exercises/src/pig_latin.rs
2020-11-24 11:26:39 +00:00

29 lines
641 B
Rust

// 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);
}
}