-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.
Description
As titled. Currently Box does not implement Deref:
fn f<G: Deref<int>>(g: &G) -> int { **g }
fn main() {
f(&std::rc::Rc::new(1i)); // ok
f(&box 1i); // error. Deref<int> not impl for Box<int>
}
But Box should be able to implement Deref.
impl<Sized? T> Deref<T> for Box<T> {
fn deref(&self) -> &T { &**self } // or any equivalent like `self.0.as_ref().unwrap()`
}
impl<Sized? T> DerefMut<T> for Box<T> {
fn deref_mut(&mut self) -> &mut T { &mut **self }
}
Metadata
Metadata
Assignees
Labels
E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.