Skip to content

Commit

Permalink
feat(encoding)!: EncodeLabel does not consume LabelEncoder
Browse files Browse the repository at this point in the history
see prometheus#135.

this adjusts the parameter of `encode()` so that it only mutably borrows
the encoder.

Signed-off-by: katelyn martin <[email protected]>
  • Loading branch information
cratelyn committed Nov 18, 2024
1 parent 12923ca commit e934279
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -343,7 +343,7 @@ impl<T: EncodeLabel> EncodeLabelSet for &[T] {
}

for label in self.iter() {
label.encode(encoder.encode_label())?
label.encode(&mut encoder.encode_label())?
}

Ok(())
Expand All @@ -363,7 +363,7 @@ impl EncodeLabelSet for NoLabelSet {
}

impl<K: EncodeLabelKey, V: EncodeLabelValue> 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()?;
Expand Down

0 comments on commit e934279

Please sign in to comment.