How to pattern match on values inside a type implementing Deref, such as Box, without copying the contents?
问题 I have data contained inside a Box , and would like to pattern match on it without accidentally copying the Box 's contents from the heap to the stack; how do I do that? Let's assume the following code: enum SomeEnum { SomeEntry, AnotherEntry, } fn main() { let boxed_value = Box::new(SomeEnum::AnotherEntry); match *boxed_value { SomeEnum::SomeEntry => {} SomeEnum::AnotherEntry => {} } } Does this copy the enum out of the box onto the stack and pattern match on that copy, or does it do the