@@ -13,9 +13,9 @@ When `BorrowMut` is derived for a newtype or struct with one field, a single
1313implementation is generated to expose the underlying field.
1414
1515``` rust
16+ # #[macro_use] extern crate derive_more;
1617# use core :: borrow :: Borrow ;
1718# use core :: borrow :: BorrowMut ;
18- # #[macro_use] extern crate derive_more;
1919# fn main (){}
2020#[derive(Borrow , BorrowMut )]
2121struct MyWrapper (String );
@@ -24,9 +24,9 @@ struct MyWrapper(String);
2424Generates:
2525
2626``` rust
27+ # #[macro_use] extern crate derive_more;
2728# use core :: borrow :: Borrow ;
2829# use core :: borrow :: BorrowMut ;
29- # #[macro_use] extern crate derive_more;
3030# #[derive(Borrow )]
3131# struct MyWrapper (String );
3232impl BorrowMut <String > for MyWrapper {
@@ -41,8 +41,9 @@ to the `borrow_mut` implementation of the field. So here `SigleFieldForward`
4141implements all ` BorrowMut ` for all types that ` Vec<i32> ` implements ` BorrowMut ` for.
4242
4343``` rust
44- # use core :: borrow :: BorrowMut ;
4544# #[macro_use] extern crate derive_more;
45+ # use core :: borrow :: Borrow ;
46+ # use core :: borrow :: BorrowMut ;
4647#[derive(Borrow , BorrowMut )]
4748#[borrow(forward)]
4849#[borrow_mut(forward)]
@@ -61,6 +62,13 @@ This generates:
6162# #[macro_use] extern crate derive_more;
6263# #[derive(Borrow )]
6364# struct SingleFieldForward (Vec <i32 >);
65+ # impl <__BorrowT: ? :: core :: marker :: Sized > :: core :: borrow :: Borrow <__BorrowT> for
66+ # SingleFieldForward where Vec <i32 >: :: core :: borrow :: Borrow <__BorrowT> {
67+ # #[inline]
68+ # fn borrow (& self ) -> & __BorrowT {
69+ # <Vec <i32 > as :: core :: borrow :: Borrow <__BorrowT>>:: borrow (& self . 0 )
70+ # }
71+ # }
6472impl <__BorrowMutT: ? :: core :: marker :: Sized > :: core :: borrow :: BorrowMut <__BorrowMutT> for SingleFieldForward
6573where
6674 Vec <i32 >: :: core :: borrow :: BorrowMut <__BorrowMutT>,
@@ -81,9 +89,9 @@ An implementation will be generated for each indicated field.
8189You can also exclude a specific field by using ` #[borrow_mut(ignore)] ` .
8290
8391``` rust
92+ # #[macro_use] extern crate derive_more;
8493# use core :: borrow :: Borrow ;
8594# use core :: borrow :: BorrowMut ;
86- # #[macro_use] extern crate derive_more;
8795# fn main (){}
8896#[derive(Borrow , BorrowMut )]
8997struct MyWrapper {
@@ -102,9 +110,9 @@ struct MyWrapper {
102110Generates:
103111
104112```
113+ # #[macro_use] extern crate derive_more;
105114# use core::borrow::Borrow;
106115# use core::borrow::BorrowMut;
107- # #[macro_use] extern crate derive_more;
108116# #[derive(Borrow)]
109117# struct MyWrapper {
110118# name: String,
@@ -128,9 +136,9 @@ Note that `BorrowMut<T>` may only be implemented once for any given type `T`. Th
128136mark more than one field of the same type with ` #[borrow_mut] ` will result in a compilation error.
129137
130138``` compile_fail
139+ # #[macro_use] extern crate derive_more;
131140# use core::borrow::Borrow;
132141# use core::borrow::BorrowMut;
133- # #[macro_use] extern crate derive_more;
134142# fn main(){}
135143// Error! Conflicting implementations of BorrowMut<String>
136144#[derive(BorrowMut)]
0 commit comments