Trait tstr::StrValue[][src]

pub trait StrValue: Debug + Copy + Default + 'static {
    const STR: &'static str;
    fn to_str(self) -> &'static str { ... }
}
This is supported 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");

}

Associated Constants

The &'static str value of this TStr.

Provided methods

Gets the &'static str value of this TStr.

Implementors