Lines Matching refs:ty
11 fn rust_type(ty: &Type) -> TokenStream {
12 match ty {
13 Type::Syn(ty) => {
14 let ident = Ident::new(ty, Span::call_site());
17 Type::Std(ty) => {
18 let ident = Ident::new(ty, Span::call_site());
21 Type::Ext(ty) => {
22 let ident = Ident::new(ty, Span::call_site());
25 Type::Token(ty) | Type::Group(ty) => {
26 let ident = Ident::new(ty, Span::call_site());
29 Type::Punctuated(ty) => {
30 let element = rust_type(&ty.element);
31 let punct = Ident::new(&ty.punct, Span::call_site());
34 Type::Option(ty) => {
35 let inner = rust_type(ty);
38 Type::Box(ty) => {
39 let inner = rust_type(ty);
42 Type::Vec(ty) => {
43 let inner = rust_type(ty);
46 Type::Tuple(ty) => {
47 let inner = ty.iter().map(rust_type);
53 fn is_printable(ty: &Type) -> bool {
54 match ty {
56 Type::Box(ty) => is_printable(ty),
57 Type::Tuple(ty) => ty.iter().any(is_printable),
63 fn format_field(val: &Operand, ty: &Type) -> Option<TokenStream> {
64 if !is_printable(ty) {
67 let format = match ty {
68 Type::Option(ty) => {
69 if let Some(format) = format_field(&Borrowed(quote!(_val)), ty) {
70 let ty = rust_type(ty);
75 struct Print(Option<#ty>);
98 Type::Tuple(ty) => {
99 let printable: Vec<TokenStream> = ty
102 .filter_map(|(i, ty)| {
106 format_field(&inner, ty)
139 Type::Syn(ty) if WHITELIST.contains(&(outer, inner)) || outer.to_owned() + inner == *ty => {
140 Some(ty)
180 let ty = &fields[0];
181 format_field(&Borrowed(val), ty).map(|format| {
198 let fields = fields.iter().enumerate().filter_map(|(i, ty)| {
201 let format = format_field(&Borrowed(val), ty)?;
229 let fields = fields.iter().filter_map(|(f, ty)| {
231 if let Type::Option(ty) = ty {
232 Some(if let Some(format) = format_field(&Owned(quote!(self.0)), ty) {
234 let ty = rust_type(ty);
239 struct Print(#ty);
262 let format = format_field(&inner, ty)?;
268 } else if let Type::Vec(_) | Type::Punctuated(_) = ty {
274 } else if let Type::Syn(inner) = ty {
279 let ty = rust_type(ty);
282 #ty::None => {}