Skip to content

Commit

Permalink
replace Ident with Path
Browse files Browse the repository at this point in the history
  • Loading branch information
ihor-rud committed Dec 23, 2024
1 parent 4682858 commit 51437a1
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions poem-openapi-derive/src/common_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ pub(crate) struct ExtraHeader {

pub(crate) enum LitOrPath<T> {
Lit(T),
Path(syn::Ident),
Path(syn::Path),
}

impl<T> darling::FromMeta for LitOrPath<T>
Expand All @@ -234,61 +234,61 @@ where
fn from_nested_meta(item: &darling::ast::NestedMeta) -> darling::Result<Self> {
T::from_nested_meta(item)
.map(Self::Lit)
.or_else(|_| syn::Ident::from_nested_meta(item).map(Self::Path))
.or_else(|_| syn::Path::from_nested_meta(item).map(Self::Path))
}

fn from_meta(item: &syn::Meta) -> darling::Result<Self> {
T::from_meta(item)
.map(Self::Lit)
.or_else(|_| syn::Ident::from_meta(item).map(Self::Path))
.or_else(|_| syn::Path::from_meta(item).map(Self::Path))
}

fn from_none() -> Option<Self> {
T::from_none()
.map(Self::Lit)
.or_else(|| syn::Ident::from_none().map(Self::Path))
.or_else(|| syn::Path::from_none().map(Self::Path))
}

fn from_word() -> darling::Result<Self> {
T::from_word()
.map(Self::Lit)
.or_else(|_| syn::Ident::from_word().map(Self::Path))
.or_else(|_| syn::Path::from_word().map(Self::Path))
}

fn from_list(items: &[darling::ast::NestedMeta]) -> darling::Result<Self> {
T::from_list(items)
.map(Self::Lit)
.or_else(|_| syn::Ident::from_list(items).map(Self::Path))
.or_else(|_| syn::Path::from_list(items).map(Self::Path))
}

fn from_value(value: &Lit) -> darling::Result<Self> {
T::from_value(value)
.map(Self::Lit)
.or_else(|_| syn::Ident::from_value(value).map(Self::Path))
.or_else(|_| syn::Path::from_value(value).map(Self::Path))
}

fn from_expr(expr: &syn::Expr) -> darling::Result<Self> {
T::from_expr(expr)
.map(Self::Lit)
.or_else(|_| syn::Ident::from_expr(expr).map(Self::Path))
.or_else(|_| syn::Path::from_expr(expr).map(Self::Path))
}

fn from_char(value: char) -> darling::Result<Self> {
T::from_char(value)
.map(Self::Lit)
.or_else(|_| syn::Ident::from_char(value).map(Self::Path))
.or_else(|_| syn::Path::from_char(value).map(Self::Path))
}

fn from_string(value: &str) -> darling::Result<Self> {
T::from_string(value)
.map(Self::Lit)
.or_else(|_| syn::Ident::from_string(value).map(Self::Path))
.or_else(|_| syn::Path::from_string(value).map(Self::Path))
}

fn from_bool(value: bool) -> darling::Result<Self> {
T::from_bool(value)
.map(Self::Lit)
.or_else(|_| syn::Ident::from_bool(value).map(Self::Path))
.or_else(|_| syn::Path::from_bool(value).map(Self::Path))
}
}

Expand Down

0 comments on commit 51437a1

Please sign in to comment.