Skip to content

async dyn Trait type deduction #64869

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
no111u3 opened this issue Sep 28, 2019 · 1 comment
Closed

async dyn Trait type deduction #64869

no111u3 opened this issue Sep 28, 2019 · 1 comment

Comments

@no111u3
Copy link

no111u3 commented Sep 28, 2019

For standart functions rust deduct conversion from Box::new(something) to Box<dyn Trait_name>, but in async we need use as Box<dyn Trait_name>:

pub trait Trait: Send {}

#[derive(Default)]
struct Test;

impl Trait for Test {}

pub fn test() -> Box<dyn Trait> {
    Box::new(Test::default())
}

pub async fn test_async() -> Box<dyn Trait> {
    Box::new(Test::default()) as Box<dyn Trait>
}

So I think it's may be better without as Box...

@memoryruins
Copy link
Contributor

Duplicate of #60424

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants