File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,13 @@ get concrete types when it is used.
11
11
#[derive(Debug)]
12
12
struct Foo(String);
13
13
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
+
14
21
impl From<u32> for Foo {
15
22
fn from(from: u32) -> Foo {
16
23
Foo(format!("Converted from integer: {from}"))
@@ -34,7 +41,7 @@ fn main() {
34
41
35
42
- The ` From ` trait will be covered later in the course, but its
36
43
[ 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 .
38
45
39
46
- Implementations of the trait do not need to cover all possible type
40
47
parameters. Here, ` Foo::from("hello") ` would not compile because there is no
You can’t perform that action at this time.
0 commit comments