diff --git a/src/lib.rs b/src/lib.rs index b6b0ad4..6705a33 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -125,10 +125,7 @@ impl Multiaddr { /// Like [`Multiaddr::push`] but consumes `self`. pub fn with(mut self, p: Protocol<'_>) -> Self { - let mut bytes = BytesMut::from(std::mem::take(&mut self.bytes)); - p.write_bytes(&mut (&mut bytes).writer()) - .expect("Writing to a `BytesMut` never fails."); - self.bytes = bytes.freeze(); + self.push(p); self } @@ -223,7 +220,7 @@ impl Multiaddr { /// Returns &str identifiers for the protocol names themselves. /// This omits specific info like addresses, ports, peer IDs, and the like. /// Example: `"/ip4/127.0.0.1/tcp/5001"` would return `["ip4", "tcp"]` - pub fn protocol_stack(&self) -> ProtoStackIter { + pub fn protocol_stack(&self) -> ProtoStackIter<'_> { ProtoStackIter { parts: self.iter() } } }