From 06cb8d50fbb016e1130f24650ac0c0ae6fb63799 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 1 Feb 2018 15:15:14 +0100 Subject: [PATCH] Make StoreId::is_in_collection() generic over AsRef --- lib/core/libimagstore/src/storeid.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/core/libimagstore/src/storeid.rs b/lib/core/libimagstore/src/storeid.rs index dde25a2e..ee36a124 100644 --- a/lib/core/libimagstore/src/storeid.rs +++ b/lib/core/libimagstore/src/storeid.rs @@ -134,14 +134,17 @@ impl StoreId { /// The collection specification _has_ to start with the module name. Otherwise this function /// may return false negatives. /// - pub fn is_in_collection(&self, colls: &[&str]) -> bool { + pub fn is_in_collection, V: AsRef<[S]>>(&self, colls: &V) -> bool { use std::path::Component; self.id .components() - .zip(colls) + .zip(colls.as_ref().iter()) .map(|(component, pred_coll)| match component { - Component::Normal(ref s) => s.to_str().map(|ref s| s == pred_coll).unwrap_or(false), + Component::Normal(ref s) => s + .to_str() + .map(|ref s| s == &pred_coll.as_ref()) + .unwrap_or(false), _ => false }) .all(|x| x)