Reimplement libimagentrylink::external::is_external_link_storeid() using StoreId::is_in_collection()

This commit is contained in:
Matthias Beyer 2016-08-28 13:41:28 +02:00
parent b2806ab592
commit d594b7c6a2

View file

@ -91,16 +91,8 @@ pub trait ExternalLinker : InternalLinker {
/// Check whether the StoreId starts with `/link/external/`
pub fn is_external_link_storeid(id: &StoreId) -> bool {
use std::path::Component;
debug!("Checking whether this is a link/external/*: '{:?}'", id);
id.components()
.take(2)
.zip(&["link", "external"])
.map(|(c, pred)| match c {
Component::Normal(ref s) => s.to_str().map(|ref s| s == pred).unwrap_or(false),
_ => false
}).all(|x| x)
id.is_in_collection(&["link", "external"])
}
fn get_external_link_from_file(entry: &FileLockEntry) -> Result<Url> {