]> git.proxmox.com Git - pathpatterns.git/commitdiff
MatchList::with_capacity and Into<Vec<MatchEntry>>
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Mon, 27 Apr 2020 14:54:38 +0000 (16:54 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Mon, 27 Apr 2020 14:54:38 +0000 (16:54 +0200)
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
src/match_list.rs

index 4c43d23106df74037c8ffd854db9d11e758673a3..3bbaecacbb6af99db9cf2f66afdb436b43cc7a4c 100644 (file)
@@ -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<MatchEntry> {
         self.list.pop()
     }
@@ -229,6 +238,12 @@ impl From<Vec<MatchEntry>> for MatchList {
     }
 }
 
+impl Into<Vec<MatchEntry>> for MatchList {
+    fn into(self) -> Vec<MatchEntry> {
+        self.list
+    }
+}
+
 impl std::ops::Deref for MatchList {
     type Target = MatchListRef;