diff options
-rw-r--r-- | src/emitter.rs | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/src/emitter.rs b/src/emitter.rs index ffd51f8..f665f47 100644 --- a/src/emitter.rs +++ b/src/emitter.rs @@ -315,9 +315,11 @@ impl<O: Offset> Emitter<O> for DefaultEmitter<O> { } fn emit_current_doctype(&mut self) { - let doctype = self.current_token.take().unwrap(); - debug_assert!(matches!(doctype, Token::Doctype(_))); - self.emit_token(doctype); + let Some(Token::Doctype(mut doctype)) = self.current_token.take() else { + debug_assert!(false); + return; + }; + self.emit_token(Token::Doctype(doctype)); } fn set_self_closing(&mut self, offset: O) { @@ -404,24 +406,18 @@ impl<O: Offset> Emitter<O> for DefaultEmitter<O> { current_attr.1.value.push_str(s); } fn init_doctype_public_id(&mut self) { - if let Some(Token::Doctype(Doctype { - ref mut public_id, .. - })) = self.current_token - { - *public_id = Some("".to_owned()); - } else { + let Some(Token::Doctype(doctype)) = &mut self.current_token else { debug_assert!(false); - } + return; + }; + doctype.public_id = Some("".to_owned()); } fn init_doctype_system_id(&mut self) { - if let Some(Token::Doctype(Doctype { - ref mut system_id, .. - })) = self.current_token - { - *system_id = Some("".to_owned()); - } else { + let Some(Token::Doctype(doctype)) = &mut self.current_token else { debug_assert!(false); - } + return; + }; + doctype.system_id = Some("".to_owned()); } fn push_doctype_public_id(&mut self, s: &str) { if let Some(Token::Doctype(Doctype { |