From e93427982907110e2095b8c9431a2f5ddc955562 Mon Sep 17 00:00:00 2001 From: katelyn martin Date: Tue, 15 Oct 2024 00:00:00 +0000 Subject: [PATCH] feat(encoding)!: `EncodeLabel` does not consume `LabelEncoder` see #135. this adjusts the parameter of `encode()` so that it only mutably borrows the encoder. Signed-off-by: katelyn martin --- src/encoding.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/encoding.rs b/src/encoding.rs index 7f77efa..a8d08ec 100644 --- a/src/encoding.rs +++ b/src/encoding.rs @@ -240,7 +240,7 @@ impl<'a> LabelSetEncoder<'a> { /// An encodable label. pub trait EncodeLabel { /// Encode oneself into the given encoder. - fn encode(&self, encoder: LabelEncoder) -> Result<(), std::fmt::Error>; + fn encode(&self, encoder: &mut LabelEncoder) -> Result<(), std::fmt::Error>; } /// Encoder for a label. @@ -343,7 +343,7 @@ impl EncodeLabelSet for &[T] { } for label in self.iter() { - label.encode(encoder.encode_label())? + label.encode(&mut encoder.encode_label())? } Ok(()) @@ -363,7 +363,7 @@ impl EncodeLabelSet for NoLabelSet { } impl EncodeLabel for (K, V) { - fn encode(&self, mut encoder: LabelEncoder) -> Result<(), std::fmt::Error> { + fn encode(&self, encoder: &mut LabelEncoder) -> Result<(), std::fmt::Error> { let (key, value) = self; let mut label_key_encoder = encoder.encode_label_key()?;