Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unnecessary clone in Key type #491

Merged
merged 1 commit into from
Mar 25, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 10 additions & 10 deletions opentelemetry/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,41 +21,41 @@ impl Key {
}

/// Create a `KeyValue` pair for `bool` values.
pub fn bool<T: Into<bool>>(&self, value: T) -> KeyValue {
pub fn bool<T: Into<bool>>(self, value: T) -> KeyValue {
KeyValue {
key: self.clone(),
key: self,
value: Value::Bool(value.into()),
}
}

/// Create a `KeyValue` pair for `i64` values.
pub fn i64(&self, value: i64) -> KeyValue {
pub fn i64(self, value: i64) -> KeyValue {
KeyValue {
key: self.clone(),
key: self,
value: Value::I64(value),
}
}

/// Create a `KeyValue` pair for `f64` values.
pub fn f64(&self, value: f64) -> KeyValue {
pub fn f64(self, value: f64) -> KeyValue {
KeyValue {
key: self.clone(),
key: self,
value: Value::F64(value),
}
}

/// Create a `KeyValue` pair for `String` values.
pub fn string<T: Into<Cow<'static, str>>>(&self, value: T) -> KeyValue {
pub fn string<T: Into<Cow<'static, str>>>(self, value: T) -> KeyValue {
KeyValue {
key: self.clone(),
key: self,
value: Value::String(value.into()),
}
}

/// Create a `KeyValue` pair for arrays.
pub fn array<T: Into<Array>>(&self, value: T) -> KeyValue {
pub fn array<T: Into<Array>>(self, value: T) -> KeyValue {
KeyValue {
key: self.clone(),
key: self,
value: Value::Array(value.into()),
}
}
Expand Down