pub struct RuleSet { /* private fields */ }
Expand description
RuleSet
is a collection of CODEOWNERS rules that can be matched together
against a given path. It is constructed by passing a Vec
of Rule
structs
to RuleSet::new
. For convenience, RuleSet::from_reader
can be used to
parse a CODEOWNERS file and construct a RuleSet
from it.
§Example
use codeowners_rs::{RuleSet, parse};
let ruleset = parse("*.rs rustacean@example.com").into_ruleset();
assert_eq!(format!("{:?}", ruleset.owners("main.rs")), "Some([Owner { value: \"rustacean@example.com\", kind: Email }])");
Implementations§
Source§impl RuleSet
impl RuleSet
Sourcepub fn matching_rule(&self, path: impl AsRef<Path>) -> Option<&Rule>
pub fn matching_rule(&self, path: impl AsRef<Path>) -> Option<&Rule>
Returns the matching rule (if any) for the given path. If multiple rules
match the path, the last matching rule in the CODEOWNERS file will be
returned. If no rules match the path, None
will be returned.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RuleSet
impl RefUnwindSafe for RuleSet
impl Send for RuleSet
impl Sync for RuleSet
impl Unpin for RuleSet
impl UnwindSafe for RuleSet
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