pub trait StrValue: Debug + Copy + Default + 'static {
const STR: &'static str;
fn to_str(self) -> &'static str { ... }
}
Available on crate feature
const_generics
only.Expand description
For getting the &'static str
value of this TStr
.
You can use this as the bound for a generic TStr
parameter.
Example
use tstr::{StrValue, ts};
asserts(ts!(foo), ts!(bar), ts!(baz));
fn asserts<A, B, C>(foo: A, bar: B, baz: C)
where
A: StrValue,
B: StrValue,
C: StrValue,
{
assert_eq!(A::STR, "foo");
assert_eq!(foo.to_str(), "foo");
assert_eq!(B::STR, "bar");
assert_eq!(bar.to_str(), "bar");
assert_eq!(C::STR, "baz");
assert_eq!(baz.to_str(), "baz");
}