MCPcopy Create free account
hub / github.com/biblius/validify / option_self_tokens_validation

Method option_self_tokens_validation

validify_derive/src/fields.rs:357–372  ·  view source on GitHub ↗

Return either `field` or `ref field` for the arg in `if let Some(arg)`.

(&self)

Source from the content-addressed store, hash-verified

355
356 /// Return either `field` or `ref field` for the arg in `if let Some(arg)`.
357 fn option_self_tokens_validation(&self) -> proc_macro2::TokenStream {
358 let ident = &self.field.ident;
359 let is_ref = self.is_reference();
360 let mut tokens = if is_ref {
361 quote!(#ident)
362 } else {
363 quote!(ref #ident)
364 };
365 let mut ty = &self.field.ty;
366
367 while let Some(typ) = try_extract_option(ty) {
368 tokens = quote!(Some(#tokens));
369 ty = typ;
370 }
371 tokens
372 }
373
374 fn option_self_tokens_modifications(&self) -> proc_macro2::TokenStream {
375 let ident = &self.field.ident;

Callers 1

wrap_tokens_if_optionMethod · 0.80

Calls 2

try_extract_optionFunction · 0.85
is_referenceMethod · 0.80

Tested by

no test coverage detected