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

Commit

Permalink
Merge pull request #21 from deg4uss3r/derive_public_parse_fn
Browse files Browse the repository at this point in the history
Adding pub to the parse functions
  • Loading branch information
Dylan-DPC authored Dec 27, 2019
2 parents 4a46684 + dfbbf86 commit 2622165
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/derives/clap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,25 +312,26 @@ pub fn derive_clap(input: &syn::DeriveInput) -> proc_macro2::TokenStream {

fn gen_parse_fns(name: &syn::Ident) -> proc_macro2::TokenStream {
quote! {
fn parse() -> #name {
#[allow(unreachable_pub)]
pub fn parse() -> #name {
use ::clap::{FromArgMatches, IntoApp};
#name::from_argmatches(&#name::into_app().get_matches())
}

fn try_parse() -> ::std::result::Result<#name, ::clap::Error> {
#[allow(unreachable_pub)]
pub fn try_parse() -> ::std::result::Result<#name, ::clap::Error> {
use ::clap::{FromArgMatches, IntoApp};
Ok(#name::from_argmatches(&#name::into_app().try_get_matches()?))
}

fn parse_from<I, T>(itr: I) -> #name
#[allow(unreachable_pub)]
pub fn parse_from<I, T>(itr: I) -> #name
where
I: ::std::iter::IntoIterator<Item = T>,
T: Into<::std::ffi::OsString> + Clone {
use ::clap::{FromArgMatches, IntoApp};
#name::from_argmatches(&#name::into_app().get_matches_from(itr))
}

fn try_parse_from<I, T>(itr: I) -> ::std::result::Result<#name, ::clap::Error>
#[allow(unreachable_pub)]
pub fn try_parse_from<I, T>(itr: I) -> ::std::result::Result<#name, ::clap::Error>
where
I: ::std::iter::IntoIterator<Item = T>,
T: Into<::std::ffi::OsString> + Clone {
Expand Down

0 comments on commit 2622165

Please sign in to comment.