/// Determine if an `#[allow(deprecated)]` should be added to the derived impl. /// /// This should happen if the derive input or an enum variant it contains has /// one of: /// - `#[deprecated]` /// - `#[allow(deprecated)]` fn should_allow_deprecated(input: &syn::DeriveInput) -> bool { if contains_deprecated(&input.attrs) { returntrue;
} iflet syn::Data::Enum(data_enum) = &input.data { for variant in &data_enum.variants { if contains_deprecated(&variant.attrs) { returntrue;
}
}
} false
}
/// Check whether the given attributes contains one of: /// - `#[deprecated]` /// - `#[allow(deprecated)]` fn contains_deprecated(attrs: &[syn::Attribute]) -> bool { for attr in attrs { if attr.path().is_ident("deprecated") { returntrue;
} iflet syn::Meta::List(meta_list) = &attr.meta { if meta_list.path.is_ident("allow") { letmut allow_deprecated = false; let _ = meta_list.parse_nested_meta(|meta| { if meta.path.is_ident("deprecated") {
allow_deprecated = true;
}
Ok(())
}); if allow_deprecated { returntrue;
}
}
}
} false
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.