From 693ac892f2db5db1ce7cf86db7bf6207b3515c42 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 13 Jul 2020 16:16:53 +0200 Subject: Don't copy-paste `impl_froms` into every crate --- crates/ra_tt/src/lib.rs | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) (limited to 'crates/ra_tt/src/lib.rs') diff --git a/crates/ra_tt/src/lib.rs b/crates/ra_tt/src/lib.rs index 342ddbe32..8faf1cc67 100644 --- a/crates/ra_tt/src/lib.rs +++ b/crates/ra_tt/src/lib.rs @@ -1,24 +1,13 @@ //! `tt` crate defines a `TokenTree` data structure: this is the interface (both //! input and output) of macros. It closely mirrors `proc_macro` crate's //! `TokenTree`. - -macro_rules! impl_froms { - ($e:ident: $($v:ident), *) => { - $( - impl From<$v> for $e { - fn from(it: $v) -> $e { - $e::$v(it) - } - } - )* - } -} - use std::{ fmt::{self, Debug}, panic::RefUnwindSafe, }; +use stdx::impl_from; + pub use smol_str::SmolStr; /// Represents identity of the token. @@ -41,7 +30,7 @@ pub enum TokenTree { Leaf(Leaf), Subtree(Subtree), } -impl_froms!(TokenTree: Leaf, Subtree); +impl_from!(Leaf, Subtree for TokenTree); impl TokenTree { pub fn empty() -> Self { @@ -55,7 +44,7 @@ pub enum Leaf { Punct(Punct), Ident(Ident), } -impl_froms!(Leaf: Literal, Punct, Ident); +impl_from!(Literal, Punct, Ident for Leaf); #[derive(Clone, PartialEq, Eq, Hash, Default)] pub struct Subtree { -- cgit v1.2.3