diff --git a/src/match_list.rs b/src/match_list.rs index 4c43d23..3bbaeca 100644 --- a/src/match_list.rs +++ b/src/match_list.rs @@ -214,10 +214,19 @@ impl MatchList { Self { list: list.into() } } + /// Create a new empty list with a specified maximum capacity. + pub fn with_capacity(capacity: usize) -> Self { + Self { + list: Vec::with_capacity(capacity) + } + } + + /// Add another entry. pub fn push(&mut self, entry: MatchEntry) { self.list.push(entry) } + /// Remove the list entry. pub fn pop(&mut self) -> Option { self.list.pop() } @@ -229,6 +238,12 @@ impl From> for MatchList { } } +impl Into> for MatchList { + fn into(self) -> Vec { + self.list + } +} + impl std::ops::Deref for MatchList { type Target = MatchListRef;