Skip to content

Commit e7392d2

Browse files
authored
mdns: simplify resource pack function (#693)
Signed-off-by: Xiaobo Liu <cppcoffee@gmail.com>
1 parent 0fd5309 commit e7392d2

File tree

1 file changed

+5
-5
lines changed
  • mdns/src/message/resource

1 file changed

+5
-5
lines changed

mdns/src/message/resource/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ impl Resource {
6565
compression: &mut Option<HashMap<String, usize>>,
6666
compression_off: usize,
6767
) -> Result<Vec<u8>> {
68-
if let Some(body) = &self.body {
69-
self.header.typ = body.real_type();
70-
} else {
71-
return Err(Error::ErrNilResourceBody);
72-
}
68+
self.header.typ = self
69+
.body
70+
.as_ref()
71+
.ok_or(Error::ErrNilResourceBody)?
72+
.real_type();
7373
let (mut msg, len_off) = self.header.pack(msg, compression, compression_off)?;
7474
let pre_len = msg.len();
7575
if let Some(body) = &self.body {

0 commit comments

Comments
 (0)