Skip to content

Commit a7db7c3

Browse files
author
Tyler Slabinski
committed
Resolve doc checks
1 parent c21ddd6 commit a7db7c3

2 files changed

Lines changed: 18 additions & 6 deletions

File tree

doc/borrow.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ When `Borrow` is derived for a newtype or struct with one field, a single
1111
implementation is generated to expose the underlying field.
1212

1313
```rust
14+
# use core::borrow::Borrow;
1415
# #[macro_use] extern crate derive_more;
1516
# fn main(){}
1617
#[derive(Borrow)]
@@ -20,6 +21,7 @@ struct MyWrapper(String);
2021
Generates:
2122

2223
```rust
24+
# use core::borrow::Borrow;
2325
# struct MyWrapper(String);
2426
impl Borrow<String> for MyWrapper {
2527
fn borrow(&self) -> &String {
@@ -33,6 +35,7 @@ to the `borrow` implementation of the field. So here `SigleFieldForward`
3335
implements all `Borrow` for all types that `Vec<i32>` implements `Borrow` for.
3436

3537
```rust
38+
# use core::borrow::Borrow;
3639
# #[macro_use] extern crate derive_more;
3740
#[derive(Borrow)]
3841
#[borrow(forward)]
@@ -49,13 +52,13 @@ This generates:
4952

5053
```rust
5154
# struct SingleFieldForward(Vec<i32>);
52-
impl<__BorrowT: ?::core::marker::Sized> ::core::convert::Borrow<__BorrowT> for SingleFieldForward
55+
impl<__BorrowT: ?::core::marker::Sized> ::core::borrow::Borrow<__BorrowT> for SingleFieldForward
5356
where
54-
Vec<i32>: ::core::convert::Borrow<__BorrowT>,
57+
Vec<i32>: ::core::borrow::Borrow<__BorrowT>,
5558
{
5659
#[inline]
5760
fn borrow(&self) -> &__BorrowT {
58-
<Vec<i32> as ::core::convert::Borrow<__BorrowT>>::borrow(&self.0)
61+
<Vec<i32> as ::core::borrow::Borrow<__BorrowT>>::borrow(&self.0)
5962
}
6063
}
6164
```
@@ -68,6 +71,7 @@ An implementation will be generated for each indicated field.
6871
You can also exclude a specific field by using `#[borrow(ignore)]`.
6972

7073
```rust
74+
# use core::borrow::Borrow;
7175
# #[macro_use] extern crate derive_more;
7276
# fn main(){}
7377
#[derive(Borrow)]
@@ -84,6 +88,7 @@ struct MyWrapper {
8488
Generates:
8589

8690
```rust
91+
# use core::borrow::Borrow;
8792
# struct MyWrapper {
8893
# name: String,
8994
# num: i32,
@@ -107,6 +112,7 @@ This means any attempt to mark more than one field of the same type with
107112
`#[borrow]` will result in a compilation error.
108113

109114
```compile_fail
115+
# use core::borrow::Borrow;
110116
# #[macro_use] extern crate derive_more;
111117
# fn main(){}
112118
// Error! Conflicting implementations of Borrow<String>

doc/borrow_mut.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ When `BorrowMut` is derived for a newtype or struct with one field, a single
1111
implementation is generated to expose the underlying field.
1212

1313
```rust
14+
# use core::borrow::BorrowMut;
1415
# #[macro_use] extern crate derive_more;
1516
# fn main(){}
1617
#[derive(BorrowMut)]
@@ -20,6 +21,7 @@ struct MyWrapper(String);
2021
Generates:
2122

2223
```rust
24+
# use core::borrow::BorrowMut;
2325
# struct MyWrapper(String);
2426
impl BorrowMut<String> for MyWrapper {
2527
fn borrow_mut(&mut self) -> &mut String {
@@ -33,6 +35,7 @@ to the `borrow_mut` implementation of the field. So here `SigleFieldForward`
3335
implements all `BorrowMut` for all types that `Vec<i32>` implements `BorrowMut` for.
3436

3537
```rust
38+
# use core::borrow::BorrowMut;
3639
# #[macro_use] extern crate derive_more;
3740
#[derive(BorrowMut)]
3841
#[borrow_mut(forward)]
@@ -49,13 +52,13 @@ This generates:
4952

5053
```rust
5154
# struct SingleFieldForward(Vec<i32>);
52-
impl<__BorrowMutT: ?::core::marker::Sized> ::core::convert::BorrowMut<__BorrowMutT> for SingleFieldForward
55+
impl<__BorrowMutT: ?::core::marker::Sized> ::core::borrow::BorrowMut<__BorrowMutT> for SingleFieldForward
5356
where
54-
Vec<i32>: ::core::convert::BorrowMut<__BorrowMutT>,
57+
Vec<i32>: ::core::borrow::BorrowMut<__BorrowMutT>,
5558
{
5659
#[inline]
5760
fn borrow_mut(&mut self) -> &mut __BorrowMutT {
58-
<Vec<i32> as ::core::convert::BorrowMut<__BorrowMutT>>::borrow_mut(&mut self.0)
61+
<Vec<i32> as ::core::borrow::BorrowMut<__BorrowMutT>>::borrow_mut(&mut self.0)
5962
}
6063
}
6164
```
@@ -69,6 +72,7 @@ An implementation will be generated for each indicated field.
6972
You can also exclude a specific field by using `#[borrow_mut(ignore)]`.
7073

7174
```rust
75+
# use core::borrow::BorrowMut;
7276
# #[macro_use] extern crate derive_more;
7377
# fn main(){}
7478
#[derive(BorrowMut)]
@@ -86,6 +90,7 @@ struct MyWrapper {
8690
Generates:
8791

8892
```
93+
# use core::borrow::BorrowMut;
8994
# struct MyWrapper {
9095
# name: String,
9196
# num: i32,
@@ -108,6 +113,7 @@ Note that `BorrowMut<T>` may only be implemented once for any given type `T`. Th
108113
mark more than one field of the same type with `#[borrow_mut]` will result in a compilation error.
109114

110115
```compile_fail
116+
# use core::borrow::BorrowMut;
111117
# #[macro_use] extern crate derive_more;
112118
# fn main(){}
113119
// Error! Conflicting implementations of BorrowMut<String>

0 commit comments

Comments
 (0)