Here's one way to do it: dereference b
("un-boxing" it to a Box
), then wrap it up immediately in another Box
, allowing the compiler to infer the correct T
(in this case Box
).
consume_func(Box::new(*b));
This works because Box
can be automatically coerced to Box
, but Box>
cannot be coerced to Box>
.