@@ -139,8 +139,8 @@ pub fn impl_default(args: TokenStream, item: TokenStream) -> TokenStream {
139139/// | [`::core::fmt::Debug`] | yes | - | |
140140/// | [`::core::hash::Hash`] | yes | - | |
141141/// | [`::core::marker::Copy`] | * | - | *allowed with `Clone` |
142- /// | [`::core::ops::Deref`] | - | deref target | `type Target` is type of target field |
143- /// | [`::core::ops::DerefMut`] | - | deref target | `type Target` is type of target field |
142+ /// | [`::core::ops::Deref`] | - | deref target | See [`Deref:: Target` type](#dereftarget-type) below |
143+ /// | [`::core::ops::DerefMut`] | - | deref target | |
144144///
145145/// Traits are matched from the path, as follows:
146146///
@@ -186,6 +186,27 @@ pub fn impl_default(args: TokenStream, item: TokenStream) -> TokenStream {
186186/// A special bound syntax, `T: trait`, indicates that `T` must support the
187187/// trait being implemented.
188188///
189+ /// ### `Deref::Target` type
190+ ///
191+ /// The [`Deref`] trait has two members:
192+ ///
193+ /// - `type Target: ?Sized`
194+ /// - `fn deref(&self) -> &Self::Target`
195+ ///
196+ /// `#[autoimpl(Deref using self.x)]` implements `Deref` as follows:
197+ ///
198+ /// - `type Target = X` where field `x` has type `X`
199+ /// - `fn deref(&self) -> &Self::Target { &self.x }`
200+ ///
201+ /// For some uses this is fine, but in other cases a different `Target` type is
202+ /// preferred. To achieve this, `Target` may be given explicitly:
203+ ///
204+ /// ```
205+ /// # use impl_tools::autoimpl;
206+ /// #[autoimpl(Deref<Target = T> using self.0)]
207+ /// struct MyBoxingWrapper<T: ?Sized>(Box<T>);
208+ /// ```
209+ ///
189210/// ### Examples
190211///
191212/// Implement `std::fmt::Debug`, ignoring the last field:
0 commit comments