diff --git a/src/tags.rs b/src/tags.rs index eb9c21f..cc1c58d 100644 --- a/src/tags.rs +++ b/src/tags.rs @@ -15,11 +15,6 @@ impl<'a> Tag<'a> { unsafe { bindings::ndb_tag_count(self.as_ptr()) } } - #[inline] - pub fn into_iter(self) -> TagIter<'a> { - TagIter::new(self) - } - pub fn get(&self, ind: u16) -> Option> { if ind >= self.count() { return None; @@ -43,12 +38,30 @@ impl<'a> Tag<'a> { } } +impl<'a> IntoIterator for Tag<'a> { + type Item = NdbStr<'a>; + type IntoIter = TagIter<'a>; + + fn into_iter(self) -> Self::IntoIter { + TagIter::new(self) + } +} + #[derive(Debug, Copy, Clone)] pub struct Tags<'a> { ptr: *mut bindings::ndb_tags, note: &'a Note<'a>, } +impl<'a> IntoIterator for Tags<'a> { + type Item = Tag<'a>; + type IntoIter = TagsIter<'a>; + + fn into_iter(self) -> Self::IntoIter { + TagsIter::new(self.note()) + } +} + impl<'a> Tags<'a> { pub(crate) fn new(ptr: *mut bindings::ndb_tags, note: &'a Note<'a>) -> Self { Tags { ptr, note }