Polish actions macros
This commit is contained in:
parent
72de5cb6ce
commit
f5f9d881d7
4 changed files with 19 additions and 11 deletions
|
@ -145,8 +145,7 @@ macro_rules! actions {
|
|||
() => {};
|
||||
|
||||
( $name:ident ) => {
|
||||
#[gpui::register_action]
|
||||
#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug, ::std::cmp::PartialEq, $crate::serde::Deserialize)]
|
||||
#[gpui::action]
|
||||
pub struct $name;
|
||||
};
|
||||
|
||||
|
|
|
@ -34,13 +34,21 @@ pub fn action(_attr: TokenStream, item: TokenStream) -> TokenStream {
|
|||
let visibility = input.vis;
|
||||
|
||||
let output = match input.data {
|
||||
syn::Data::Struct(ref struct_data) => {
|
||||
syn::Data::Struct(ref struct_data) => match &struct_data.fields {
|
||||
syn::Fields::Named(_) | syn::Fields::Unnamed(_) => {
|
||||
let fields = &struct_data.fields;
|
||||
quote! {
|
||||
#attributes
|
||||
#visibility struct #name #fields
|
||||
}
|
||||
}
|
||||
syn::Fields::Unit => {
|
||||
quote! {
|
||||
#attributes
|
||||
#visibility struct #name;
|
||||
}
|
||||
}
|
||||
},
|
||||
syn::Data::Enum(ref enum_data) => {
|
||||
let variants = &enum_data.variants;
|
||||
quote! {
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
use gpui::actions;
|
||||
|
||||
// todo!(remove this)
|
||||
// If the zed binary doesn't use anything in this crate, it will be optimized out
|
||||
// and the actions won't initialize. So we just call an empty initialization function.
|
||||
// https://github.com/rust-lang/rust/issues/47384
|
||||
// https://github.com/mmastrac/rust-ctor/issues/280
|
||||
pub fn unused() {}
|
||||
pub fn init() {}
|
||||
|
||||
actions!(
|
||||
Cancel,
|
||||
|
|
|
@ -59,7 +59,7 @@ fn main() {
|
|||
//TODO!(figure out what the linker issues are here)
|
||||
// https://github.com/rust-lang/rust/issues/47384
|
||||
// https://github.com/mmastrac/rust-ctor/issues/280
|
||||
menu::unused();
|
||||
// menu::unused();
|
||||
let http = http::client();
|
||||
init_paths();
|
||||
init_logger();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue