diff --git a/src/traits/default.md b/src/traits/default.md index a19c8d01..ca5241dc 100644 --- a/src/traits/default.md +++ b/src/traits/default.md @@ -1,6 +1,6 @@ # The `Default` Trait -`Default` trait provides a default implementation of a trait. +[`Default`][1] trait provides a default implementation of a trait. ```rust,editable #[derive(Debug, Default)] @@ -45,3 +45,5 @@ fn main() { * Rust standard library is aware that types can implement `Default` and provides convenience methods that use it. + +[1]: https://doc.rust-lang.org/std/default/trait.Default.html diff --git a/src/traits/drop.md b/src/traits/drop.md index 2c5a5a22..7b3345a7 100644 --- a/src/traits/drop.md +++ b/src/traits/drop.md @@ -1,6 +1,6 @@ # The `Drop` Trait -Values which implement `Drop` can specify code to run when they go out of scope: +Values which implement [`Drop`][1] can specify code to run when they go out of scope: ```rust,editable struct Droppable { @@ -39,4 +39,6 @@ Discussion points: overflow! * Try replacing `drop(a)` with `a.drop()`. - \ No newline at end of file + + +[1]: https://doc.rust-lang.org/std/ops/trait.Drop.html diff --git a/src/traits/from-into.md b/src/traits/from-into.md index c25013c6..fe480441 100644 --- a/src/traits/from-into.md +++ b/src/traits/from-into.md @@ -1,6 +1,6 @@ # `From` and `Into` -Types implement `From` and `Into` to facilitate type conversions: +Types implement [`From`][1] and [`Into`][2] to facilitate type conversions: ```rust,editable fn main() { @@ -12,7 +12,7 @@ fn main() { } ``` -`Into` is automatically implemented when `From` is implemented: +[`Into`][2] is automatically implemented when [`From`][1] is implemented: ```rust,editable fn main() { @@ -31,3 +31,6 @@ fn main() { Your function will accept types that implement `From` and those that _only_ implement `Into`. + +[1]: https://doc.rust-lang.org/std/convert/trait.From.html +[2]: https://doc.rust-lang.org/std/convert/trait.Into.html diff --git a/src/traits/from-iterator.md b/src/traits/from-iterator.md index ebaad7bf..4fa3ac9c 100644 --- a/src/traits/from-iterator.md +++ b/src/traits/from-iterator.md @@ -1,6 +1,6 @@ # FromIterator -`FromIterator` lets you build a collection from an `Iterator`. +[`FromIterator`][1] lets you build a collection from an [`Iterator`][2]. ```rust,editable fn main() { @@ -24,3 +24,6 @@ There are also implementations which let you do cool things like convert an `Iterator>` into a `Result, E>`. + +[1]: https://doc.rust-lang.org/std/iter/trait.FromIterator.html +[2]: https://doc.rust-lang.org/std/iter/trait.Iterator.html diff --git a/src/traits/important-traits.md b/src/traits/important-traits.md index 22900166..b7ce7362 100644 --- a/src/traits/important-traits.md +++ b/src/traits/important-traits.md @@ -2,9 +2,20 @@ We will now look at some of the most common traits of the Rust standard library: -* `Iterator` and `IntoIterator` used in `for` loops, -* `From` and `Into` used to convert values, -* `Read` and `Write` used for IO, -* `Add`, `Mul`, ... used for operator overloading, and -* `Drop` used for defining destructors. -* `Default` used to construct a default instance of a type. +* [`Iterator`][1] and [`IntoIterator`][2] used in `for` loops, +* [`From`][3] and [`Into`][4] used to convert values, +* [`Read`][5] and [`Write`][6] used for IO, +* [`Add`][7], [`Mul`][8], ... used for operator overloading, and +* [`Drop`][9] used for defining destructors. +* [`Default`][10] used to construct a default instance of a type. + +[1]: https://doc.rust-lang.org/std/iter/trait.Iterator.html +[2]: https://doc.rust-lang.org/std/iter/trait.IntoIterator.html +[3]: https://doc.rust-lang.org/std/convert/trait.From.html +[4]: https://doc.rust-lang.org/std/convert/trait.Into.html +[5]: https://doc.rust-lang.org/std/io/trait.Read.html +[6]: https://doc.rust-lang.org/std/io/trait.Write.html +[7]: https://doc.rust-lang.org/std/ops/trait.Add.html +[8]: https://doc.rust-lang.org/std/ops/trait.Mul.html +[9]: https://doc.rust-lang.org/std/ops/trait.Drop.html +[10]: https://doc.rust-lang.org/std/default/trait.Default.html diff --git a/src/traits/iterator.md b/src/traits/iterator.md index 770fbe0e..c4108f90 100644 --- a/src/traits/iterator.md +++ b/src/traits/iterator.md @@ -1,6 +1,6 @@ # Iterators -You can implement the `Iterator` trait on your own types: +You can implement the [`Iterator`][1] trait on your own types: ```rust,editable struct Fibonacci { @@ -37,3 +37,5 @@ fn main() { implementations. + +[1]: https://doc.rust-lang.org/std/iter/trait.Iterator.html diff --git a/src/traits/operators.md b/src/traits/operators.md index 8388178b..b683f210 100644 --- a/src/traits/operators.md +++ b/src/traits/operators.md @@ -1,6 +1,6 @@ # `Add`, `Mul`, ... -Operator overloading is implemented via traits in `std::ops`: +Operator overloading is implemented via traits in [`std::ops`][1]: ```rust,editable #[derive(Debug, Copy, Clone)] @@ -35,4 +35,6 @@ Discussion points: associated types (like `Output`) are controlled by the implementor of a trait. - \ No newline at end of file + + +[1]: https://doc.rust-lang.org/std/ops/index.html diff --git a/src/traits/read-write.md b/src/traits/read-write.md index c363fc36..d9238dfc 100644 --- a/src/traits/read-write.md +++ b/src/traits/read-write.md @@ -1,6 +1,6 @@ # `Read` and `Write` -Using `Read` and `BufRead`, you can abstract over `u8` sources: +Using [`Read`][1] and [`BufRead`][2], you can abstract over `u8` sources: ```rust,editable use std::io::{BufRead, BufReader, Read, Result}; @@ -20,7 +20,7 @@ fn main() -> Result<()> { } ``` -Similarly, `Write` lets you abstract over `u8` sinks: +Similarly, [`Write`][3] lets you abstract over `u8` sinks: ```rust,editable use std::io::{Result, Write}; @@ -38,3 +38,7 @@ fn main() -> Result<()> { Ok(()) } ``` + +[1]: https://doc.rust-lang.org/std/io/trait.Read.html +[2]: https://doc.rust-lang.org/std/io/trait.BufRead.html +[3]: https://doc.rust-lang.org/std/io/trait.Write.html