From ebc9c58838e2b74b7f7b8c6bc567ac73b67d4573 Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Mon, 17 Aug 2020 11:40:33 +0200 Subject: [PATCH] Remove doc::ItemType::class method We only query the item class for two variants. It is easier to hardcode this two classes instead of providing all available classes. --- src/doc.rs | 31 ------------------------------- src/parser/mod.rs | 4 ++-- 2 files changed, 2 insertions(+), 33 deletions(-) diff --git a/src/doc.rs b/src/doc.rs index ddc5b2d..4c07d03 100644 --- a/src/doc.rs +++ b/src/doc.rs @@ -243,37 +243,6 @@ impl ItemType { } } - pub fn class(&self) -> &str { - match self { - ItemType::Module => "module", - ItemType::ExternCrate => "extern-crate", - ItemType::Import => "import", - ItemType::Struct => "struct", - ItemType::Enum => "enum", - ItemType::Function => "function", - ItemType::Typedef => "type", - ItemType::Static => "static", - ItemType::Trait => "trait", - ItemType::Impl => "impl", - ItemType::TyMethod => "required-method", - ItemType::Method => "method", - ItemType::StructField => "structfield", - ItemType::Variant => "variant", - ItemType::Macro => "macro", - ItemType::Primitive => "primitive", - ItemType::AssocType => "associated-type", - ItemType::Constant => "constant", - ItemType::AssocConst => "associated-const", - ItemType::Union => "union", - ItemType::ForeignType => "foreign-type", - ItemType::Keyword => "keyword", - ItemType::OpaqueTy => "opaque-type", - ItemType::ProcAttribute => "proc-attribute", - ItemType::ProcDerive => "proc-derive", - ItemType::TraitAlias => "trait-alias", - } - } - pub fn group_name(&self) -> &str { match self { ItemType::Module => "Modules", diff --git a/src/parser/mod.rs b/src/parser/mod.rs index 1180801..3472285 100644 --- a/src/parser/mod.rs +++ b/src/parser/mod.rs @@ -275,7 +275,7 @@ fn get_fields( let mut definition: Option = None; while let Some(element) = &next { - if element.is_element(&local_name!("span")) && element.has_class(ty.class()) { + if element.is_element(&local_name!("span")) && element.has_class("structfield") { fields.push(&mut name, &mut definition, None)?; name = get_id_part(element, 1); definition = Some(element.into()); @@ -476,7 +476,7 @@ fn get_variants( let mut definition: Option = None; while let Some(element) = &next { if element.is_element(&local_name!("div")) { - if element.has_class(ty.class()) { + if element.has_class("variant") { variants.push(&mut name, &mut definition, None)?; name = get_id_part(element, 1); definition = Some(element.into());