From 766fb2a9e266c3f3a38eee374656e67705bbcee4 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 10 Apr 2016 18:43:02 +0200 Subject: [PATCH] Implement remove_external_link() --- libimaglink/src/external.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/libimaglink/src/external.rs b/libimaglink/src/external.rs index e091c70d..4c91ad3f 100644 --- a/libimaglink/src/external.rs +++ b/libimaglink/src/external.rs @@ -106,7 +106,7 @@ pub trait ExternalLinker : InternalLinker { fn add_external_link(&mut self, store: &Store, link: Url) -> Result<()>; /// Remove an external link from the implementor object - fn remove_external_link(&mut self, link: Url) -> Result<()>; + fn remove_external_link(&mut self, store: &Store, link: Url) -> Result<()>; } @@ -213,9 +213,15 @@ impl ExternalLinker for Entry { } /// Remove an external link from the implementor object - fn remove_external_link(&mut self, link: Url) -> Result<()> { + fn remove_external_link(&mut self, store: &Store, link: Url) -> Result<()> { // get external links, remove this one, save them - unimplemented!() + self.get_external_links(store) + .and_then(|mut links| { + let links = links.into_iter() + .filter(|l| l.serialize() != link.serialize()) + .collect(); + self.set_external_links(store, links) + }) } }