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
pub struct Params<'a> {
raw: &'a str,
pub trailing: Option<&'a str>
}
impl<'a> Params<'a> {
pub fn new(raw: &'a str) -> Params<'a> {
let trailing = raw.find(" :").map(|index| &raw[index + 2..]);
Params {
raw,
trailing
}
}
pub fn iter(&self) -> impl Iterator<Item = &'a str> {
match self.raw.find(" :") {
Some(index) => self.raw[..index].split_whitespace(),
None => self.raw.split_whitespace()
}
}
}
impl<'a> ToString for Params<'a> {
fn to_string(&self) -> String {
self.raw.to_string()
}
}