From 1046241be6fe85b0bc460e4d26535924db6875ea Mon Sep 17 00:00:00 2001 From: Rustln Date: Mon, 21 Mar 2022 17:33:27 +0800 Subject: [PATCH] Add `#[macro_export]` to custom marco --- src/advance/into-types/enum-int.md | 1 + 1 file changed, 1 insertion(+) diff --git a/src/advance/into-types/enum-int.md b/src/advance/into-types/enum-int.md index f9e924a8..a6641664 100644 --- a/src/advance/into-types/enum-int.md +++ b/src/advance/into-types/enum-int.md @@ -139,6 +139,7 @@ fn main() { 但是上面的代码有个问题,你需要为每个枚举成员都实现一个转换分支,非常麻烦。好在可以使用宏来简化,自动根据枚举的定义来实现`TryFrom`特征: ```rust +#[macro_export] macro_rules! back_to_enum { ($(#[$meta:meta])* $vis:vis enum $name:ident { $($(#[$vmeta:meta])* $vname:ident $(= $val:expr)?,)*