Update ch15-02-deref.md

This commit is contained in:
Daniel 2021-07-18 12:47:57 +08:00 committed by GitHub
parent db0fe0c209
commit 58f744a567
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -155,7 +155,7 @@ Rust 将 `*` 运算符替换为先调用 `deref` 方法再进行普通解引用
**解引用强制多态**_deref coercions_是 Rust 在函数或方法传参上的一种便利。解引用强制多态只能工作在实现了Deref trait的类型上。解引用强制多态将一种类型A隐式转换为另外一种类型B的引用因为A类型实现了Deref trait并且其关联类型是B类型。比如解引用强制多态可以将&String转换为&str因为类型String实现了Deref trait并且其关联类型是str。代码如下
```rust
```rust,ignore
#[stable(feature = "rust1", since = "1.0.0")]
impl ops::Deref for String {
type Target = str;