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/serde_derive/src/de/unit.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 / serde_derive / src / de / unit.rs` 52 lines ยท 1916 bytes Raw Blame History 1 use crate::de::Parameters; 2 use crate::fragment::Fragment; 3 use crate::internals::attr; 4 use crate::private; 5 use quote::quote; 6 7 /// Generates `Deserialize::deserialize` body for a `struct Unit;` 8 pub(super) fn deserialize(params: &Parameters, cattrs: &attr::Container) -> Fragment { 9 let this_type = ¶ms.this_type; 10 let this_value = ¶ms.this_value; 11 let type_name = cattrs.name().deserialize_name(); 12 let (de_impl_generics, de_ty_generics, ty_generics, where_clause) = 13 params.generics_with_de_lifetime(); 14 let delife = params.borrowed.de_lifetime(); 15 16 let expecting = format!("unit struct {}", params.type_name()); 17 let expecting = cattrs.expecting().unwrap_or(&expecting); 18 19 quote_block! { 20 #[doc(hidden)] 21 struct __Visitor #de_impl_generics #where_clause { 22 marker: _serde::#private::PhantomData<#this_type #ty_generics>, 23 lifetime: _serde::#private::PhantomData<&#delife ()>, 24 } 25 26 #[automatically_derived] 27 impl #de_impl_generics _serde::de::Visitor<#delife> for __Visitor #de_ty_generics #where_clause { 28 type Value = #this_type #ty_generics; 29 30 fn expecting(&self, __formatter: &mut _serde::#private::Formatter) -> _serde::#private::fmt::Result { 31 _serde::#private::Formatter::write_str(__formatter, #expecting) 32 } 33 34 #[inline] 35 fn visit_unit<__E>(self) -> _serde::#private::Result 36 where 37 __E: _serde::de::Error, 38 { 39 _serde::#private::Ok(#this_value) 40 } 41 } 42 43 _serde::Deserializer::deserialize_unit_struct( 44 __deserializer, 45 #type_name, 46 __Visitor { 47 marker: _serde::#private::PhantomData::<#this_type #ty_generics>, 48 lifetime: _serde::#private::PhantomData, 49 }, 50 ) 51 } 52 }