diff --git a/src/intensity.rs b/src/intensity.rs index 8f00e63..ce3ebcf 100644 --- a/src/intensity.rs +++ b/src/intensity.rs @@ -12,6 +12,7 @@ pub struct Intensity { } impl Intensity { + /// Creates new instance from vec of passes and their names pub fn new(level: u64, passes: Vec<(String, Pass)>) -> Self { let (names, passes) = passes.into_iter().unzip(); @@ -22,7 +23,8 @@ impl Intensity { } } - /// Produces new instance by extending inner passes + /// Merges it's own passes with other. Passes for existing names are replaced while new ones + /// are placed at the end of resulting new Intensity #[allow(clippy::result_large_err)] pub fn extend( &self, diff --git a/src/pass.rs b/src/pass.rs index 0f93c3b..34e71f2 100644 --- a/src/pass.rs +++ b/src/pass.rs @@ -18,7 +18,7 @@ pub struct Pass { // skips 20 pages of debug output of `multi_regex` field impl fmt::Debug for Pass { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("UnnamedPass") + f.debug_struct("Pass") .field("patterns", &self.regexes) .field("tags", &self.tags) .finish() @@ -26,6 +26,7 @@ impl fmt::Debug for Pass { } impl Pass { + /// Creates new instance from vec of regex and tag pairs #[allow(clippy::result_large_err)] pub fn new(rules: Vec<(String, Box)>) -> Result { let (patterns, tags): (Vec<_>, Vec<_>) = rules.into_iter().unzip(); @@ -46,13 +47,15 @@ impl Pass { }) } + /// Merges it's own regexes with other. Tags for existing regexes are replaced while new ones + /// are placed at the end of resulting new Pass #[allow(clippy::result_large_err)] pub fn extend(&self, other: Pass) -> Result { let mut existing_rules: Vec<_> = self .regexes .iter() .cloned() - .zip(self.tags.iter().cloned()) + .zip(self.tags.clone()) .collect(); let mut appended_rules = Vec::new(); @@ -79,6 +82,7 @@ impl Pass { Self::new(existing_rules) } + /// Produces string with all non-overlapping regexes replaced by corresponding tags pub fn apply<'a>(&self, text: &'a str) -> Cow<'a, str> { let all_captures: Vec<_> = self.multi_regex.captures_iter(text).collect();