aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2023-08-17 17:47:04 +0200
committerMartin Fischer <martin@push-f.com>2023-08-19 13:41:55 +0200
commite34083e64b764df076c1ef9ec6bf1102b9fbf748 (patch)
tree6f4ce04d3546455e9a4669984a8c25f666798d7a /src
parentc07334e7bb613774d3535663433c90b6dde86943 (diff)
chore: use let...else
Diffstat (limited to 'src')
-rw-r--r--src/emitter.rs30
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 {