Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/blob/main/vendor/syn-2.0.119/tests/debug/mod.rs # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienux / vendor / syn-2.0.119 / tests / debug / mod.rs` 147 lines ยท 3340 bytes Raw Blame History 1 #![allow( 2 clippy::no_effect_underscore_binding, 3 clippy::too_many_lines, 4 clippy::used_underscore_binding 5 )] 6 7 #[rustfmt::skip] 8 mod gen; 9 10 use proc_macro2::{Ident, Literal, TokenStream}; 11 use ref_cast::RefCast; 12 use std::fmt::{self, Debug}; 13 use std::ops::Deref; 14 use syn::punctuated::Punctuated; 15 16 #[derive(RefCast)] 17 #[repr(transparent)] 18 pub struct Lite { 19 value: T, 20 } 21 22 #[allow(non_snake_case)] 23 pub fn Lite(value: &T) -> &Lite { 24 Lite::ref_cast(value) 25 } 26 27 impl Deref for Lite { 28 type Target = T; 29 30 fn deref(&self) -> &Self::Target { 31 &self.value 32 } 33 } 34 35 impl Debug for Lite { 36 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { 37 write!(formatter, "{}", self.value) 38 } 39 } 40 41 impl Debug for Lite { 42 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { 43 write!(formatter, "{}", self.value) 44 } 45 } 46 47 impl Debug for Lite { 48 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { 49 write!(formatter, "{}", self.value) 50 } 51 } 52 53 impl Debug for Lite { 54 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { 55 write!(formatter, "{:?}", self.value) 56 } 57 } 58 59 impl Debug for Lite { 60 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { 61 write!(formatter, "{:?}", self.value.to_string()) 62 } 63 } 64 65 impl Debug for Lite { 66 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { 67 write!(formatter, "{}", self.value) 68 } 69 } 70 71 impl Debug for Lite { 72 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { 73 let string = self.value.to_string(); 74 if string.len() <= 80 { 75 write!(formatter, "TokenStream(`{}`)", self.value) 76 } else { 77 formatter 78 .debug_tuple("TokenStream") 79 .field(&format_args!("`{}`", string)) 80 .finish() 81 } 82 } 83 } 84 85 impl Debug for Lite<&T> 86 where 87 Lite: Debug, 88 { 89 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { 90 Debug::fmt(Lite(self.value), formatter) 91 } 92 } 93 94 impl Debug for Lite> 95 where 96 Lite: Debug, 97 { 98 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { 99 Debug::fmt(Lite(&*self.value), formatter) 100 } 101 } 102 103 impl Debug for Lite> 104 where 105 Lite: Debug, 106 { 107 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { 108 formatter 109 .debug_list() 110 .entries(self.value.iter().map(Lite)) 111 .finish() 112 } 113 } 114 115 impl Debug for Lite> 116 where 117 Lite: Debug, 118 Lite

: Debug, 119 { 120 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { 121 let mut list = formatter.debug_list(); 122 for pair in self.pairs() { 123 let (node, punct) = pair.into_tuple(); 124 list.entry(Lite(node)); 125 list.entries(punct.map(Lite)); 126 } 127 list.finish() 128 } 129 } 130 131 struct Present; 132 133 impl Debug for Present { 134 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { 135 formatter.write_str("Some") 136 } 137 } 138 139 struct Option { 140 present: bool, 141 } 142 143 impl Debug for Option { 144 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { 145 formatter.write_str(if self.present { "Some" } else { "None" }) 146 } 147 }