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

Function is_map

validify_derive/src/fields.rs:430–445  ·  view source on GitHub ↗
(ty: &syn::Type)

Source from the content-addressed store, hash-verified

428}
429
430fn is_map(ty: &syn::Type) -> bool {
431 if let Some(ty) = try_extract_option(ty) {
432 return is_map(ty);
433 }
434
435 let syn::Type::Path(p) = ty else {
436 return false;
437 };
438
439 // Always check the last arg such as in `std::vec::Vec`
440 let Some(seg) = p.path.segments.last() else {
441 return false;
442 };
443
444 seg.ident == "HashMap" || seg.ident == "BTreeMap" || seg.ident == "IndexMap"
445}
446
447fn try_extract_option(ty: &syn::Type) -> Option<&syn::Type> {
448 let syn::Type::Path(p) = ty else {

Callers 1

is_mapMethod · 0.85

Calls 1

try_extract_optionFunction · 0.85

Tested by

no test coverage detected