From 9bed77f50b7fc9d2487acede3560a86f2dbe95cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Wed, 22 Oct 2025 00:17:44 +0200 Subject: [PATCH 1/2] Implement with() in terms of push() The bodies are identical --- src/lib.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index b6b0ad4..fb112a2 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 } From e24eb1c009309291a32ec1078837c0d75591ca7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Wed, 22 Oct 2025 00:42:01 +0200 Subject: [PATCH 2/2] Fix critical(?) mismatched_lifetime_syntaxes --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index fb112a2..6705a33 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -220,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() } } }