diff --git a/zenoh/src/api/publisher.rs b/zenoh/src/api/publisher.rs index 2a0a47047b..ec8a8aff35 100644 --- a/zenoh/src/api/publisher.rs +++ b/zenoh/src/api/publisher.rs @@ -360,7 +360,8 @@ impl<'a> Publisher<'a> { } fn undeclare_matching_listeners(&self) -> ZResult<()> { - for id in zlock!(self.matching_listeners).drain() { + let ids: Vec = zlock!(self.matching_listeners).drain().collect(); + for id in ids { self.session.undeclare_matches_listener_inner(id)? } Ok(())