pub trait TStrArg: __TStrRepr + 'static { }Expand description
For bounding the type parameter of TStr.
You only need this trait if you’re using using TStr explicitly in the code,
it’s usually better have a type parameter bounded by
the IsTStr trait instead of using TStr directly.
This trait is sealed and cannot be implemented outside of the tstr crate.
§Example
This example shows a usecase where you’ll need to use this trait,
implementing traits for TStr.
use tstr::{IsTStr, TStr, TStrArg, ts};
assert_eq!("hello".my_as_str(), "hello");
assert_eq!(ts!(world).my_as_str(), "world");
trait MyAsStr {
fn my_as_str(&self) -> &str;
}
impl MyAsStr for &str {
fn my_as_str(&self) -> &str { self }
}
impl<S: TStrArg> MyAsStr for TStr<S> {
fn my_as_str(&self) -> &str { self.to_str() }
}Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.