Download editor/src/macros.rs from openfree/graphite2: direct link, hf CLI and curl.
- Browser
- Download file 1.1 kB
-
https://huggingface.co/spaces/openfree/graphite2/resolve/main/editor/src/macros.rs
- Command line
-
hf download hf://spaces/openfree/graphite2/editor/src/macros.rs
-
curl -L -o macros.rs https://huggingface.co/spaces/openfree/graphite2/resolve/main/editor/src/macros.rs
1.1 kB
| /// Syntax sugar for initializing an `ActionList` | |
| /// | |
| /// # Example | |
| /// | |
| /// ```ignore | |
| /// actions!(DocumentMessage::Undo, DocumentMessage::Redo); | |
| /// ``` | |
| /// | |
| /// expands to: | |
| /// ```ignore | |
| /// vec![vec![DocumentMessage::Undo, DocumentMessage::Redo]]; | |
| /// ``` | |
| /// | |
| /// and | |
| /// ```ignore | |
| /// actions!(DocumentMessage; | |
| /// Undo, | |
| /// Redo, | |
| /// ); | |
| /// ``` | |
| /// | |
| /// expands to: | |
| /// ```ignore | |
| /// vec![vec![DocumentMessage::Undo, DocumentMessage::Redo]]; | |
| /// ``` | |
| /// | |
| macro_rules! actions { | |
| ($($v:expr_2021),* $(,)?) => {{ | |
| vec![$(vec![$v.into()]),*] | |
| }}; | |
| ($name:ident; $($v:ident),* $(,)?) => {{ | |
| vec![vec![$(($name::$v).into()),*]] | |
| }}; | |
| } | |
| /// Does the same thing as the `actions!` macro but wraps everything in: | |
| /// | |
| /// ```ignore | |
| /// fn actions(&self) -> ActionList { | |
| /// actions!(…) | |
| /// } | |
| /// ``` | |
| macro_rules! advertise_actions { | |
| ($($v:expr_2021),* $(,)?) => { | |
| fn actions(&self) -> $crate::utility_traits::ActionList { | |
| actions!($($v),*) | |
| } | |
| }; | |
| ($name:ident; $($v:ident),* $(,)?) => { | |
| fn actions(&self) -> $crate::utility_traits::ActionList { | |
| actions!($name; $($v),*) | |
| } | |
| } | |
| } | |