diff --git a/actix-router/CHANGES.md b/actix-router/CHANGES.md index 49248d05..087d67ac 100644 --- a/actix-router/CHANGES.md +++ b/actix-router/CHANGES.md @@ -7,7 +7,7 @@ * Fix a bug in multi-patterns where static patterns are interpreted as regex. [#366] * Introduce `ResourceDef::pattern_iter` to get an iterator over all patterns in a multi-pattern resource. [#373] * Fix segment interpolation leaving `Path` in unintended state after matching. [#368] -* Fix `ResourceDef` `PartialEq` implementation. +* Fix `ResourceDef` `PartialEq` implementation. [#373] * Re-work `IntoPatterns` trait, adding a `Patterns` enum. [#372] * Implement `IntoPatterns` for `bytestring::ByteString`. [#372] * Rename `Path::{len => segment_count}` to be more descriptive of it's purpose. [#370] diff --git a/actix-router/src/lib.rs b/actix-router/src/lib.rs index f08b25a8..463e59e4 100644 --- a/actix-router/src/lib.rs +++ b/actix-router/src/lib.rs @@ -49,6 +49,15 @@ pub enum Patterns { List(Vec), } +impl Patterns { + pub fn is_empty(&self) -> bool { + match self { + Patterns::Single(_) => false, + Patterns::List(pats) => pats.is_empty(), + } + } +} + /// Helper trait for type that could be converted to one or more path pattern. pub trait IntoPatterns { fn patterns(&self) -> Patterns; @@ -78,6 +87,12 @@ impl IntoPatterns for bytestring::ByteString { } } +impl IntoPatterns for Patterns { + fn patterns(&self) -> Patterns { + self.clone() + } +} + impl> IntoPatterns for Vec { fn patterns(&self) -> Patterns { let mut patterns = self.iter().map(|v| v.as_ref().to_owned());