Skip to content

Commit

Permalink
fix: make <mi> buildable, improve rendering API (#8)
Browse files Browse the repository at this point in the history
* fix: make `Ident` buildable

* fix: improve rendering API
  • Loading branch information
nfejzic committed Dec 8, 2023
1 parent db4f8e2 commit 81e55b5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/elements/mi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub struct IdentBuilder<T> {

impl<T> IdentBuilder<T> {
/// Set the identifier string for the [`Ident`] element.
pub fn ident(self, ident: impl Into<String>) -> IdentBuilder<Uninit> {
pub fn ident(self, ident: impl Into<String>) -> IdentBuilder<Init> {
IdentBuilder {
ident: Some(ident.into()),
attributes: self.attributes,
Expand Down
8 changes: 6 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,16 +125,20 @@ impl MathMl {
}

/// Write this `math` element and its children using the given writer.
pub fn write<W: Writer>(&self, writer: &mut W) -> Result<W::Buffer, W::Error> {
pub fn write<'writer, W: Writer>(
&self,
writer: &'writer mut W,
) -> Result<&'writer mut W, W::Error> {
writer.write_mathml(self)?;
Ok(writer.finish())
Ok(writer)
}

/// Render this `math` element and its children using the default renderer.
///
/// In this implementation, [`BufMathMlWriter`] is used.
pub fn render(&self) -> Result<String, <BufMathMlWriter as crate::Writer>::Error> {
self.write(&mut BufMathMlWriter::default())
.map(|w| w.finish())
}
}

Expand Down

0 comments on commit 81e55b5

Please sign in to comment.