Consider the following code:
pub struct FooManager<T> {
data: Vec<T>,
}
impl FooManager<T> {
fn new() -> FooManager {
foo { data: Vec::new() }
}
pub fn get_per_thread() -> &FooManager {
&MANAGER<T>
}
}
thread_local! {
static MANAGER<T>: FooManager<T> = FooManager::new();
}
If we dropped the <T>
, it is easy to make the code work. Question is: is there a way t make thsi work with the <T>
, i.e. I want to be able to have:
FooManager<usize>, FooManager<String>, FooManager<Cat>, FooManager<Dog>
and have a separate thread_local variable created for each.