Simplify implementation of add_tag()
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
parent
061c5beb85
commit
e95a4cd15d
1 changed files with 5 additions and 13 deletions
|
@ -91,20 +91,12 @@ impl Tagable for Value {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_tag(&mut self, t: Tag) -> Result<()> {
|
fn add_tag(&mut self, t: Tag) -> Result<()> {
|
||||||
if !is_tag_str(&t).map(|_| true)
|
let _ = is_tag_str(&t)?;
|
||||||
.map_err(|s| format_err!("{}", s))
|
|
||||||
.context(err_msg("Not a tag"))?
|
|
||||||
{
|
|
||||||
return Err(format_err!("Not a tag: '{}'", t));
|
|
||||||
}
|
|
||||||
|
|
||||||
self.get_tags()
|
let mut tags = self.get_tags()?;
|
||||||
.map(|mut tags| {
|
|
||||||
debug!("Pushing tag = {:?} to list = {:?}", t, tags);
|
debug!("Pushing tag = {:?} to list = {:?}", t, tags);
|
||||||
tags.push(t);
|
tags.push(t);
|
||||||
self.set_tags(&tags.into_iter().unique().collect::<Vec<_>>()[..])
|
self.set_tags(&tags)
|
||||||
})
|
|
||||||
.map(|_| ())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn remove_tag(&mut self, t: Tag) -> Result<()> {
|
fn remove_tag(&mut self, t: Tag) -> Result<()> {
|
||||||
|
|
Loading…
Reference in a new issue