Fix doctest (fixup –#25900)

This commit is contained in:
Manish Goregaokar 2015-06-04 11:26:31 +05:30
parent 5ef7614243
commit fd3b6ca508
1 changed files with 19 additions and 18 deletions

View File

@ -3699,28 +3699,29 @@ Coercion is allowed between the following types:
* `&mut T` to `*mut T`.
* `&T` to `&U` if `T` implements `Deref<Target = U>`. For example:
```
use std::ops::Deref;
struct CharContainer {
value: char
```rust
use std::ops::Deref;
struct CharContainer {
value: char
}
impl Deref for CharContainer {
type Target = char;
fn deref<'a>(&'a self) -> &'a char {
&self.value
}
}
impl Deref for CharContainer {
type Target = char;
fn foo(arg: &char) {}
fn deref<'a>(&'a self) -> &'a char {
&self.value
}
}
fn foo(arg: &char) {}
fn main() {
let x = &mut CharContainer { value: 'y' };
foo(x); //&mut CharContainer is coerced to &char.
}
```
fn main() {
let x = &mut CharContainer { value: 'y' };
foo(x); //&mut CharContainer is coerced to &char.
}
```
* `&mut T` to `&mut U` if `T` implements `DerefMut<Target = U>`.
* TyCtor(`T`) to TyCtor(coerce_inner(`T`)), where TyCtor(`T`) is one of