pub struct TestStruct<T: str+usize>{ // of course this is incorrect, but don't know how to set it.
pub data: Vec<T>
}
normally use the T generics, but for some special cases , I want to explicitly set the args type such as : &str or usize.
how to write this ristriction?
thanks advanced.
You can write different implementations for the concrete types TestStruct<&'_ str> and TestStruct<usize>. Although that seems like a weird requirement. Can't you just implement a custom trait for str and usize instead?