Skip to content

Remove unnecessary public APIs for creating KeyValue structs #2090

@utpilla

Description

@utpilla

We have an additional set of public APIs to create KeyValue struct apart from KeyValue::new(). These APIs don't offer anything additional in terms of feature or performance. They simply offer an alternative way to create KeyValue struct by creating the Key first and then the Value instead of having them created together.

I think we could remove these APIs just to keep our public API surface smaller. I'm opening this issue to check if anyone has any opinions on this.

pub fn bool<T: Into<bool>>(self, value: T) -> KeyValue {
KeyValue {
key: self,
value: Value::Bool(value.into()),
}
}
/// Create a `KeyValue` pair for `i64` values.
pub fn i64(self, value: i64) -> KeyValue {
KeyValue {
key: self,
value: Value::I64(value),
}
}
/// Create a `KeyValue` pair for `f64` values.
pub fn f64(self, value: f64) -> KeyValue {
KeyValue {
key: self,
value: Value::F64(value),
}
}
/// Create a `KeyValue` pair for string-like values.
pub fn string(self, value: impl Into<StringValue>) -> KeyValue {
KeyValue {
key: self,
value: Value::String(value.into()),
}
}
/// Create a `KeyValue` pair for arrays.
pub fn array<T: Into<Array>>(self, value: T) -> KeyValue {
KeyValue {
key: self,
value: Value::Array(value.into()),
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-metricsArea: issues related to metricsA-traceArea: issues related to tracinghelp wantedGood for taking. Extra help will be provided by maintainers/approvers

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions