Skip to content

Commit 7bbaabc

Browse files
fix(clippy): box OAuthFlows and use slice::contains
Two clippy errors caught only with `--all-features -- -D warnings`: - large_enum_variant: SecurityScheme::OAuth2 carried OAuthFlows directly (~817 bytes); other variants ~97 bytes. Box it so the enum's variants are similarly sized. - manual_contains: schema_types.iter().any(|t| *t == X) → contains(&X). Plus drop the only `expect_used` in catalog-gen.rs by replacing the `get_mut(...).expect(...)` with an `if let Some(...)` guard. `cargo clippy --all-features -- -D warnings` is now clean. Refs #14
1 parent 0f4b80f commit 7bbaabc

2 files changed

Lines changed: 10 additions & 9 deletions

File tree

src/bin/catalog-gen.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,11 @@ fn parse(md: &str) -> Catalog {
211211
continue;
212212
}
213213
if let Some(field) = parse_field_row(line) {
214-
let entry = catalog
215-
.objects
216-
.get_mut(object)
217-
.expect("object inserted on heading");
218-
match kind {
219-
TableKind::Fixed => entry.fields.push(field),
220-
TableKind::Patterned => entry.patterned_fields.push(field),
214+
if let Some(entry) = catalog.objects.get_mut(object) {
215+
match kind {
216+
TableKind::Fixed => entry.fields.push(field),
217+
TableKind::Patterned => entry.patterned_fields.push(field),
218+
}
221219
}
222220
}
223221
}

src/openapi.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,10 @@ pub enum SecurityScheme {
446446
},
447447
#[serde(rename = "oauth2")]
448448
OAuth2 {
449-
flows: OAuthFlows,
449+
// Boxed to keep the SecurityScheme enum's variants similarly sized
450+
// (the OAuthFlows tree is ~800 bytes; clippy::large_enum_variant
451+
// flagged the disparity).
452+
flows: Box<OAuthFlows>,
450453
#[serde(default)]
451454
description: Option<String>,
452455
/// 3.2 §"Security Scheme Object" — well-known metadata URL (D4).
@@ -600,7 +603,7 @@ impl Schema {
600603
pub fn type_array_contains_null(&self) -> bool {
601604
match self {
602605
Schema::TypedMulti { schema_types, .. } => {
603-
schema_types.iter().any(|t| *t == SchemaType::Null)
606+
schema_types.contains(&SchemaType::Null)
604607
}
605608
_ => false,
606609
}

0 commit comments

Comments
 (0)