Hi everyone,
I'm looking for a way to call new on an alias type like the following:
type Flag = Arc<Mutex<bool>>
Because the following doesn't work:
flag : Flag::new(false);
Any ideas?
Thank you very much!
Hi everyone,
I'm looking for a way to call new on an alias type like the following:
type Flag = Arc<Mutex<bool>>
Because the following doesn't work:
flag : Flag::new(false);
Any ideas?
Thank you very much!
For now, you can't:
https://github.com/rust-lang/rust/issues/11047
There's no Arc::<Mutex<bool>>::new(bool)
so how could that have worked?
Now I have the following:
flag: Arc<Mutex<bool>>
flag: Arc::new(Mutex::new(false));
I mean, that type you're aliasing Flag
to doesn't have a new
constructor that takes bool
. But you can add a constructor with a different name.
Ah, ok. I just wanted to know if the compiler was able to figure it out by itself.