Skip to content
This repository was archived by the owner on May 11, 2020. It is now read-only.

feat: Allow empty struct without braces #19

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/no_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use clap::{AppSettings, Clap};
author = "",
raw(global_setting = "AppSettings::DisableVersion")
)]
struct Opt {}
struct Opt;

fn main() {
let opt = Opt::parse();
Expand Down
8 changes: 8 additions & 0 deletions src/derives/clap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,14 @@ pub fn derive_clap(input: &syn::DeriveInput) -> proc_macro2::TokenStream {
fields: syn::Fields::Named(ref fields),
..
}) => clap_impl_for_struct(struct_name, &fields.named, &input.attrs),
Struct(syn::DataStruct {
fields: syn::Fields::Unit,
..
}) => clap_impl_for_struct(
struct_name,
&punctuated::Punctuated::<syn::Field, token::Comma>::new(),
&input.attrs,
),
Enum(ref e) => clap_impl_for_enum(struct_name, &e.variants, &input.attrs),
_ => panic!("clap_derive only supports non-tuple structs and enums"),
};
Expand Down