Initial pig latin
This commit is contained in:
28
src/pig_latin.rs
Normal file
28
src/pig_latin.rs
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user