Add iterators and convenience functions
Dependencies
- [2]
3UXSFGJYUpdate `gemini`: Convenience methods, make streaming parsers public; update tests - [*]
J4PKMKJXAdd root doc comment, gemtext module - [*]
M5HGUS2TAdd parser tests and fix some bugs
Change contents
- edit in gemini/src/gemtext.rs at line 116
}/// Add a link line without a name to the document.pub fn link_unnamed(self, to: impl Into<String>) -> Self {let to = to.into();self.push(Doc::Link { to, name: None }) - edit in gemini/src/gemtext.rs at line 170
}/// An iterator over references to the documents in the builder.pub fn iter(&self) -> impl Iterator<Item = &Doc> {self.docs.iter()}/// An iterator over mutable references to the documents in the builder.pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut Doc> {self.docs.iter_mut() - edit in gemini/src/gemtext.rs at line 217
impl IntoIterator for Builder {type Item = Doc;type IntoIter = std::vec::IntoIter<Doc>; - edit in gemini/src/gemtext.rs at line 223
fn into_iter(self) -> Self::IntoIter {self.docs.into_iter()}} - edit in gemini/src/gemtext.rs at line 556[5.5534][5.5534]
#[test]fn test_iter() {let expected = [Doc::Blank,Doc::Heading(Level::One, "Wow!".to_string()),Doc::Quote("Wee!".to_string()),Doc::Link {to: "gemini://foo.bar".to_string(),name: None,},];let doc = Builder::new().line().h1("Wow!").quote("Wee!").link_unnamed("gemini://foo.bar");for (i, actual) in doc.iter().enumerate() {assert_eq!(actual, &expected[i])}}