Skip to content

Commit 06d17f7

Browse files
authored
OtelString::Owned uses Box<str> instead of String (#1096)
1 parent eb90492 commit 06d17f7

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

opentelemetry-api/src/common.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ impl From<&'static str> for Key {
8888
impl From<String> for Key {
8989
/// Convert a `String` to a `Key`.
9090
fn from(string: String) -> Self {
91-
Key(OtelString::Owned(string))
91+
Key(OtelString::Owned(string.into_boxed_str()))
9292
}
9393
}
9494

@@ -104,7 +104,7 @@ impl From<Cow<'static, str>> for Key {
104104
fn from(string: Cow<'static, str>) -> Self {
105105
match string {
106106
Cow::Borrowed(s) => Key(OtelString::Static(s)),
107-
Cow::Owned(s) => Key(OtelString::Owned(s)),
107+
Cow::Owned(s) => Key(OtelString::Owned(s.into_boxed_str())),
108108
}
109109
}
110110
}
@@ -118,7 +118,7 @@ impl fmt::Debug for Key {
118118
impl From<Key> for String {
119119
fn from(key: Key) -> Self {
120120
match key.0 {
121-
OtelString::Owned(s) => s,
121+
OtelString::Owned(s) => s.to_string(),
122122
OtelString::Static(s) => s.to_string(),
123123
OtelString::RefCounted(s) => s.to_string(),
124124
}
@@ -137,8 +137,8 @@ impl fmt::Display for Key {
137137

138138
#[derive(Clone, Debug, Eq)]
139139
enum OtelString {
140+
Owned(Box<str>),
140141
Static(&'static str),
141-
Owned(String),
142142
RefCounted(Arc<str>),
143143
}
144144

@@ -290,7 +290,7 @@ impl StringValue {
290290
impl From<StringValue> for String {
291291
fn from(s: StringValue) -> Self {
292292
match s.0 {
293-
OtelString::Owned(s) => s,
293+
OtelString::Owned(s) => s.to_string(),
294294
OtelString::Static(s) => s.to_string(),
295295
OtelString::RefCounted(s) => s.to_string(),
296296
}
@@ -305,7 +305,7 @@ impl From<&'static str> for StringValue {
305305

306306
impl From<String> for StringValue {
307307
fn from(s: String) -> Self {
308-
StringValue(OtelString::Owned(s))
308+
StringValue(OtelString::Owned(s.into_boxed_str()))
309309
}
310310
}
311311

@@ -318,7 +318,7 @@ impl From<Arc<str>> for StringValue {
318318
impl From<Cow<'static, str>> for StringValue {
319319
fn from(s: Cow<'static, str>) -> Self {
320320
match s {
321-
Cow::Owned(s) => StringValue(OtelString::Owned(s)),
321+
Cow::Owned(s) => StringValue(OtelString::Owned(s.into_boxed_str())),
322322
Cow::Borrowed(s) => StringValue(OtelString::Static(s)),
323323
}
324324
}

0 commit comments

Comments
 (0)