How can you call new on an alias type?


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:


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.