Make StoreId::is_in_collection() generic over AsRef<str>
This commit is contained in:
parent
eb6ab8f029
commit
06cb8d50fb
1 changed files with 6 additions and 3 deletions
|
@ -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<S: AsRef<str>, 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)
|
||||
|
|
Loading…
Reference in a new issue