File tree 1 file changed +31
-1
lines changed
src/2018/transitioning/modules
1 file changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ Now, you write:
30
30
31
31
``` rust,ignore
32
32
// Rust 2018
33
- #![feature(rust_2018_preview, use_extern_macros )]
33
+ #![feature(rust_2018_preview)]
34
34
35
35
use bar::baz;
36
36
@@ -41,6 +41,36 @@ fn main() {
41
41
42
42
This moves ` macro_rules ` macros to be a bit closer to other kinds of items.
43
43
44
+
45
+ ## Procedural macros
46
+
47
+ When using procedural macros to derive traits, you will have to name the macro
48
+ that provides the custom derive. This generally matches the name of the trait,
49
+ but check with the documentation of the crate providing the derives to be sure.
50
+
51
+ For example, with Serde you would have written
52
+
53
+ ``` rust,ignore
54
+ // Rust 2015
55
+ extern crate serde;
56
+ #[macro_use] extern crate serde_derive;
57
+
58
+ #[derive(Serialize, Deserialize)]
59
+ struct Bar;
60
+ ```
61
+
62
+ Now, you write instead:
63
+
64
+ ``` rust,ignore
65
+ // Rust 2018
66
+ #![feature(rust_2018_preview)]
67
+ use serde_derive::{Serialize, Deserialize};
68
+
69
+ #[derive(Serialize, Deserialize)]
70
+ struct Bar;
71
+ ```
72
+
73
+
44
74
## More details
45
75
46
76
This only works for macros defined in external crates.
You can’t perform that action at this time.
0 commit comments