Require documentation on reader public items.

This commit is contained in:
Jakob Stoklund Olesen
2016-10-26 17:43:18 -07:00
parent 447baf015e
commit e2418c6ec9
4 changed files with 21 additions and 0 deletions

View File

@@ -14,19 +14,27 @@
use std::fmt::{self, Display, Formatter};
/// A command appearing in a test file.
#[derive(Clone, PartialEq, Eq, Debug)]
pub struct TestCommand<'a> {
/// The command name as a string.
pub command: &'a str,
/// The options following the command name.
pub options: Vec<TestOption<'a>>,
}
/// An option on a test command.
#[derive(Clone, PartialEq, Eq, Debug)]
pub enum TestOption<'a> {
/// Single identifier flag: `foo`.
Flag(&'a str),
/// A value assigned to an identifier: `foo=bar`.
Value(&'a str, &'a str),
}
impl<'a> TestCommand<'a> {
/// Create a new TestCommand by parsing `s`.
/// The returned command contains references into `s`.
pub fn new(s: &'a str) -> TestCommand<'a> {
let mut parts = s.split_whitespace();
let cmd = parts.next().unwrap_or("");
@@ -48,6 +56,8 @@ impl<'a> Display for TestCommand<'a> {
}
impl<'a> TestOption<'a> {
/// Create a new TestOption by parsing `s`.
/// The returned option contains references into `s`.
pub fn new(s: &'a str) -> TestOption<'a> {
match s.find('=') {
None => TestOption::Flag(s),