pub struct Directive<'a> {
pub key: Key,
pub reason: Option<&'a str>,
}Fields§
§key: KeyA directive key, declaring the nature of this Directive.
reason: Option<&'a str>Implementations§
Source§impl<'a> Directive<'a>
impl<'a> Directive<'a>
Sourcepub fn parse_from_str(content: &'a str) -> Result<Self>
pub fn parse_from_str(content: &'a str) -> Result<Self>
Parse Directive from a &str.
§Examples
Parsing a TAP directive may look like this:
use tapconsooomer::Directive;
use tapconsooomer::Key;
let content = "# SKIP hardware requirements not met";
let directive = Directive::parse_from_str(content).expect("Parser error");
assert!(matches!(directive.key, Key::Skip));
assert_eq!(directive.reason, Some("hardware requirements not met"));Note, Directive::reason is optional:
use tapconsooomer::Directive;
use tapconsooomer::Key;
let content = "# TODO";
let directive = Directive::parse_from_str(content).expect("Parser error");
assert!(matches!(directive.key, Key::Todo));
assert_eq!(directive.reason, None);Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Directive<'a>
impl<'a> RefUnwindSafe for Directive<'a>
impl<'a> Send for Directive<'a>
impl<'a> Sync for Directive<'a>
impl<'a> Unpin for Directive<'a>
impl<'a> UnwindSafe for Directive<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more