1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
//! Converts strings to pig latin.
//! # Use
//! ```text
//! igpay "example string"
//! ```
//!
//! Igpay will remove all capital letters and puctuation. It is the simplest form of a pig latin
//! translator.
//! In addition to this, it cannot be piped into:
//! ```text
//! echo "hello" | igpay
//! ```
//!
//! Pig latin is not a well-defined language. As a result of this, Igpay's idea of pig latin may not be the same as another translator's.
//!
//! ### The rules for Igpay's translation are as follows:
//! - All strings inputted to Igpay are trimmed.
//! - All strings inputted to Igpay are converted to lowercase.
//!
//! #### For words beginning with an English consonant
//! - Words have that first consonant removed and appended to
//! the end of the string.
//! - The string `"ay "` (notice the trailing whitespace) is appended to the string.
//!
//! #### For words beginning with an vowel defined in [VOWELS](https://docs.rs/igpay/latest/igpay/constant.VOWELS.html)
//! - Words have the string `"hay "` (notice the trailing whitespace) appended to them.
//!
//! #### After (applies to all)
//! - All words are pushed to a new string.
//! - Resulting string is trimmed, then returned.
/// Array of vowels in English.
/// # Examples
///
/// - VOWELS can be used simply as a useful
/// [array](https://doc.rust-lang.org/stable/std/primitive.array.html) of English vowels:
/// ```
/// use igpay::VOWELS;
///
/// let letter = VOWELS[3];
///
/// assert_eq!(letter, 'o');
/// ```
///
/// - It can, however, also be used to check a
/// [char](https://doc.rust-lang.org/stable/std/primitive.char.html) to find if it is a vowel:
/// ```
/// use igpay::VOWELS;
///
/// let foo = "an example";
///
/// let mut is_vowel: Vec<bool> = Vec::new();
///
/// for character in foo.chars() {
/// is_vowel.push(VOWELS.contains(&character));
/// }
///
/// assert_eq!(is_vowel, vec![
/// true, false, false, true, false, true, false, false, false, true
/// ]);
/// ```
pub const VOWELS: = ;
/// `to_platin` is the main function for converting
/// [&str](https://doc.rust-lang.org/stable/std/primitive.str.html)s into pig-latinified
/// [String](https://doc.rust-lang.org/stable/std/struct.string.html)s.
///
/// # Basic Use
/// ```
/// igpay::to_platin("A str.");
/// ```
///
/// # Examples
///
/// ```
/// let foo = "Hello, amazing world!";
/// let bar = String::from("Hello, amazing world!");
///
/// assert_eq!("ellohay amazinghay orldway", igpay::to_platin(foo));
///
/// // Of course, to_platin works with a &String too as it coerces to &str.
/// assert_eq!("ellohay amazinghay orldway", igpay::to_platin(&bar));
/// ```
///
/// ### Dealing with non-English strings
/// `to_platin` is designed only for use with the English language, or languages that have the same vowel
/// configuration as is defined in [VOWELS](https://docs.rs/igpay/latest/igpay/constant.VOWELS.html).
///
/// **This doesn't mean `to_platin` won't try!**
///
/// There is no functionality for `to_platin` to
/// [panic](https://doc.rust-lang.org/stable/std/macro.panic.html) or return an error etc. if it
/// encounters a language that it is not designed for.
///
/// It will follow the same rules as usual:
/// ```
/// assert_eq!(igpay::to_platin("あ"), "あay");
/// ```
///
/// # Panics
/// `to_platin` will only panic if the value at pos 0 in the chars iterator returns None.
/// This probably will never happen, though, and so should be reported as an issue on [the GitHub
/// page](https://github.com/ajmull/igpay).