1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
use std::borrow::Cow;

pub struct StringValue(pub Cow<'static, str>);

pub trait IntoStringValue {
	fn into_string_value(self) -> StringValue;
}

impl IntoStringValue for Cow<'static, str> {
	fn into_string_value(self) -> StringValue {
		StringValue(self)
	}
}

impl IntoStringValue for String {
	fn into_string_value(self) -> StringValue {
		StringValue(Cow::Owned(self))
	}
}

impl IntoStringValue for &'static str {
	fn into_string_value(self) -> StringValue {
		StringValue(Cow::Borrowed(self))
	}
}