Create a new TestCommand by parsing `s`. The returned command contains references into `s`.
(s: &'a str)
| 36 | /// Create a new TestCommand by parsing `s`. |
| 37 | /// The returned command contains references into `s`. |
| 38 | pub fn new(s: &'a str) -> Self { |
| 39 | let mut parts = s.split_whitespace(); |
| 40 | let cmd = parts.next().unwrap_or(""); |
| 41 | Self { |
| 42 | command: cmd, |
| 43 | options: parts |
| 44 | .filter(|s| !s.is_empty()) |
| 45 | .map(TestOption::new) |
| 46 | .collect(), |
| 47 | } |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | impl<'a> Display for TestCommand<'a> { |