Is there any way to convert Box> to Box>?

后端 未结 2 1958
眼角桃花
眼角桃花 2021-01-21 14:49

Consider such code:

trait Foo {
    fn foo(&self);
}

fn consume_func(b: Box>) {
    unimplemented!();
}

fn produce_func() -> Box<         


        
2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-21 15:07

    Although you've stated you cannot change consume_func, others with similar issues can change it to accept a generic:

    fn consume_func(b: Box>) {
        unimplemented!();
    }
    

提交回复
热议问题