I wrote a function to return either either std::sync::Mutex or tokio::sync::Mutex
// MUTEX can be either std::sync::Mutex or tokio::sync::Mutex
fn create_lock<MUTEX>() -> std::sync::Arc<MUTEX<i64>> {
std::sync::Arc::new(MUTEX::new(0))
}
The compiler throws the following error:
| fn create_lock<MUTEX>() -> std::sync::Arc<MUTEX<i64>> {
| ^^^ type argument not allowed
That would require higher kinded types. This is unsupported by rustc. As alternative you can rewrite it a bit to use generic associated types which are currently unstable.
You need a trait either way to specify the amount of type arguments. You can't avoid the struct without higher kinded types which we don't support in favor of generic associated types.