1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
use proc_macro::{LexError}; pub struct MacroError { pub msg : String, } impl<'a> From<&'a str> for MacroError { fn from(m:&'a str) -> MacroError { MacroError { msg : m.to_owned() } } } impl From<String> for MacroError { fn from(m:String) -> MacroError { MacroError { msg : m } } } impl From<LexError> for MacroError { fn from(_:LexError) -> MacroError { MacroError { msg : "Error parsing token stream".to_owned() } } }