pub struct Document {
pub paragraphs: Vec<Paragraph>,
}Expand description
A collection of top-level Paragraph nodes that make up an FTML document.
The struct is intentionally lightweight: it simply stores the top-level paragraphs in the order in which they should render.
§Examples
Building a document manually:
use tdoc::{Document, Paragraph, Span};
let mut doc = Document::new();
let paragraph = Paragraph::new_text().with_content(vec![Span::new_text("Hello!")]);
doc.add_paragraph(paragraph);
assert_eq!(doc.paragraphs.len(), 1);
assert!(!doc.is_empty());Fields§
§paragraphs: Vec<Paragraph>Implementations§
Source§impl Document
impl Document
Sourcepub fn with_paragraphs(self, paragraphs: Vec<Paragraph>) -> Self
pub fn with_paragraphs(self, paragraphs: Vec<Paragraph>) -> Self
Replaces the document’s paragraphs, returning the updated document.
Sourcepub fn add_paragraph(&mut self, paragraph: Paragraph)
pub fn add_paragraph(&mut self, paragraph: Paragraph)
Appends a new paragraph to the end of the document.
Trait Implementations§
impl StructuralPartialEq for Document
Auto Trait Implementations§
impl Freeze for Document
impl RefUnwindSafe for Document
impl Send for Document
impl Sync for Document
impl Unpin for Document
impl UnwindSafe for Document
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more