diff options
Diffstat (limited to '')
-rw-r--r-- | src/doc/book/redirects/borrow-and-asref.md | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/doc/book/redirects/borrow-and-asref.md b/src/doc/book/redirects/borrow-and-asref.md new file mode 100644 index 000000000..6541e59ba --- /dev/null +++ b/src/doc/book/redirects/borrow-and-asref.md @@ -0,0 +1,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 |