mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-06-12 16:41:01 +00:00
Look inside of None-delimited groups when examining types
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
use internals::symbol::*;
|
||||
use internals::Ctxt;
|
||||
use internals::{ungroup, Ctxt};
|
||||
use proc_macro2::{Group, Span, TokenStream, TokenTree};
|
||||
use quote::ToTokens;
|
||||
use std::borrow::Cow;
|
||||
@@ -1737,7 +1737,7 @@ fn is_implicitly_borrowed_reference(ty: &syn::Type) -> bool {
|
||||
// cow: Cow<'a, str>,
|
||||
// }
|
||||
fn is_cow(ty: &syn::Type, elem: fn(&syn::Type) -> bool) -> bool {
|
||||
let path = match ty {
|
||||
let path = match ungroup(ty) {
|
||||
syn::Type::Path(ty) => &ty.path,
|
||||
_ => {
|
||||
return false;
|
||||
@@ -1764,7 +1764,7 @@ fn is_cow(ty: &syn::Type, elem: fn(&syn::Type) -> bool) -> bool {
|
||||
}
|
||||
|
||||
fn is_option(ty: &syn::Type, elem: fn(&syn::Type) -> bool) -> bool {
|
||||
let path = match ty {
|
||||
let path = match ungroup(ty) {
|
||||
syn::Type::Path(ty) => &ty.path,
|
||||
_ => {
|
||||
return false;
|
||||
@@ -1811,7 +1811,7 @@ fn is_option(ty: &syn::Type, elem: fn(&syn::Type) -> bool) -> bool {
|
||||
// r: &'a str,
|
||||
// }
|
||||
fn is_reference(ty: &syn::Type, elem: fn(&syn::Type) -> bool) -> bool {
|
||||
match ty {
|
||||
match ungroup(ty) {
|
||||
syn::Type::Reference(ty) => ty.mutability.is_none() && elem(&ty.elem),
|
||||
_ => false,
|
||||
}
|
||||
@@ -1822,14 +1822,14 @@ fn is_str(ty: &syn::Type) -> bool {
|
||||
}
|
||||
|
||||
fn is_slice_u8(ty: &syn::Type) -> bool {
|
||||
match ty {
|
||||
match ungroup(ty) {
|
||||
syn::Type::Slice(ty) => is_primitive_type(&ty.elem, "u8"),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
fn is_primitive_type(ty: &syn::Type, primitive: &str) -> bool {
|
||||
match ty {
|
||||
match ungroup(ty) {
|
||||
syn::Type::Path(ty) => ty.qself.is_none() && is_primitive_path(&ty.path, primitive),
|
||||
_ => false,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user