diff --git a/crates/header-translator/src/method.rs b/crates/header-translator/src/method.rs index c03bc1bb9..bdc834997 100644 --- a/crates/header-translator/src/method.rs +++ b/crates/header-translator/src/method.rs @@ -57,7 +57,7 @@ impl MethodModifiers { fn parse(entity: &Entity<'_>, context: &Context<'_>) -> Self { let mut this = Self::default(); - immediate_children(&entity, |entity, _span| match entity.get_kind() { + immediate_children(entity, |entity, _span| match entity.get_kind() { EntityKind::UnexposedAttr => { if let Some(attr) = UnexposedAttr::parse(&entity, context) { match attr { @@ -610,12 +610,10 @@ impl fmt::Display for Method { error!("invalid mutating method"); } // Insert nothing; a class method is assumed + } else if self.mutating { + write!(f, "&mut self, ")?; } else { - if self.mutating { - write!(f, "&mut self, ")?; - } else { - write!(f, "&self, ")?; - } + write!(f, "&self, ")?; } // Arguments diff --git a/crates/header-translator/src/rust_type.rs b/crates/header-translator/src/rust_type.rs index 2b53472f0..7da9659cb 100644 --- a/crates/header-translator/src/rust_type.rs +++ b/crates/header-translator/src/rust_type.rs @@ -151,10 +151,11 @@ impl Drop for AttributeParser<'_, '_> { } } -#[derive(Deserialize, Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[derive(Deserialize, Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Default)] #[serde(from = "bool")] pub enum Ownership { Owned, + #[default] Shared, } @@ -168,12 +169,6 @@ impl From for Ownership { } } -impl Default for Ownership { - fn default() -> Self { - Ownership::Shared - } -} - impl fmt::Display for Ownership { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self {