We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent cd8d911 commit cc72a67Copy full SHA for cc72a67
1 file changed
tests/for_deref.rs
@@ -117,3 +117,30 @@ fn gat() {
117
impls_gat(S);
118
impls_gat(Box::new(S));
119
}
120
+
121
+#[test]
122
+fn custom_deref_target() {
123
+ #[autoimpl(Deref<Target = T>, DerefMut using self.0)]
124
+ struct BoxingWrapper<T: ?Sized>(Box<T>);
125
126
+ #[autoimpl(for<T: trait + ?Sized> BoxingWrapper<T>)]
127
+ trait Increment {
128
+ fn increment(&mut self);
129
+ }
130
131
+ impl Increment for i32 {
132
+ fn increment(&mut self) {
133
+ *self += 1;
134
135
136
137
+ let mut x = BoxingWrapper(Box::new(0));
138
+ x.increment();
139
+ assert_eq!(*x.0, 1);
140
141
+ let mut y = 10;
142
+ y.increment();
143
+ let mut z = BoxingWrapper(Box::new(&mut y as &mut dyn Increment));
144
+ z.increment();
145
+ assert_eq!(y, 12);
146
+}
0 commit comments