Skip to content

Commit b3734de

Browse files
authored
Include the From trait in the generic traits slide (#2570)
This saves a bunch of tabbing back and forth from the docs to the slide.
1 parent b3c57e4 commit b3734de

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/generics/generic-traits.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ get concrete types when it is used.
1111
#[derive(Debug)]
1212
struct Foo(String);
1313
14+
/* https://doc.rust-lang.org/stable/std/convert/trait.From.html
15+
*
16+
* pub trait From<T>: Sized {
17+
* fn from(value: T) -> Self;
18+
* }
19+
*/
20+
1421
impl From<u32> for Foo {
1522
fn from(from: u32) -> Foo {
1623
Foo(format!("Converted from integer: {from}"))
@@ -34,7 +41,7 @@ fn main() {
3441

3542
- The `From` trait will be covered later in the course, but its
3643
[definition in the `std` docs](https://doc.rust-lang.org/std/convert/trait.From.html)
37-
is simple.
44+
is simple, and copied here for reference.
3845

3946
- Implementations of the trait do not need to cover all possible type
4047
parameters. Here, `Foo::from("hello")` would not compile because there is no

0 commit comments

Comments
 (0)