summaryrefslogtreecommitdiffstats
path: root/src/doc/book/redirects/borrow-and-asref.md
blob: 6541e59bafbe08435b0746d4ee5fbf973945efa0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
% Borrow and AsRef

<small>There is a new edition of the book and this is an old link.</small>

> A cheap reference-to-reference conversion.
> Used to convert a value to a reference value within generic code.

```rust
fn is_hello<T: AsRef<str>>(s: T) {
   assert_eq!("hello", s.as_ref());
}
```

---

This chapter does not exist in [the second edition][2].
The best place to learn more about this is [the Rust documentation][3].

* **[In the Rust documentation: `convert::AsRef`][3]**
* <small>[In the first edition: Ch 4.10 — Borrow and AsRef][1]</small>


[1]: https://doc.rust-lang.org/1.30.0/book/first-edition/borrow-and-asref.html
[2]: index.html
[3]: ../std/convert/trait.AsRef.html