diff --git a/src/pxar/match_pattern.rs b/src/pxar/match_pattern.rs index b4048d87..c5af8f28 100644 --- a/src/pxar/match_pattern.rs +++ b/src/pxar/match_pattern.rs @@ -60,13 +60,28 @@ pub enum MatchType { /// # Ok(()) /// # } /// ``` -#[derive(Clone)] +#[derive(Eq, PartialOrd)] pub struct MatchPattern { pattern: Vec, match_positive: bool, match_dir_only: bool, } +impl std::cmp::PartialEq for MatchPattern { + fn eq(&self, other: &Self) -> bool { + self.pattern == other.pattern + && self.match_positive == other.match_positive + && self.match_dir_only == other.match_dir_only + } +} + +impl std::cmp::Ord for MatchPattern { + fn cmp(&self, other: &Self) -> std::cmp::Ordering { + (&self.pattern, &self.match_positive, &self.match_dir_only) + .cmp(&(&other.pattern, &other.match_positive, &other.match_dir_only)) + } +} + impl MatchPattern { /// Read a list of `MatchPattern` from file. /// The file is read line by line (lines terminated by newline character),