diff --git a/glib/src/object.rs b/glib/src/object.rs index 9eefb0dc591a..9d722b4e7e33 100644 --- a/glib/src/object.rs +++ b/glib/src/object.rs @@ -1750,11 +1750,13 @@ pub trait ObjectExt: ObjectType { #[doc(alias = "g_object_get_property")] fn property_value(&self, property_name: &str) -> Value; + // rustdoc-stripper-ignore-next + /// Check if the object has a property `property_name`. + fn has_property(&self, property_name: &str) -> bool; + // rustdoc-stripper-ignore-next /// Check if the object has a property `property_name` of the given `type_`. - /// - /// If no type is provided then only the existence of the property is checked. - fn has_property(&self, property_name: &str, type_: Option) -> bool; + fn has_property_with_type(&self, property_name: &str, type_: Type) -> bool; // rustdoc-stripper-ignore-next /// Get the type of the property `property_name` of this object. @@ -2455,8 +2457,13 @@ impl ObjectExt for T { } } - fn has_property(&self, property_name: &str, type_: Option) -> bool { - self.object_class().has_property(property_name, type_) + fn has_property(&self, property_name: &str) -> bool { + self.object_class().has_property(property_name) + } + + fn has_property_with_type(&self, property_name: &str, type_: Type) -> bool { + self.object_class() + .has_property_with_type(property_name, type_) } fn property_type(&self, property_name: &str) -> Option { @@ -3316,16 +3323,15 @@ fn validate_signal_arguments(type_: Type, signal_query: &SignalQuery, args: &mut pub unsafe trait ObjectClassExt { // rustdoc-stripper-ignore-next /// Check if the object class has a property `property_name` of the given `type_`. - /// - /// If no type is provided then only the existence of the property is checked. - fn has_property(&self, property_name: &str, type_: Option) -> bool { - let ptype = self.property_type(property_name); + fn has_property(&self, property_name: &str) -> bool { + self.find_property(property_name).is_some() + } - match (ptype, type_) { - (None, _) => false, - (Some(_), None) => true, - (Some(ptype), Some(type_)) => ptype == type_, - } + // rustdoc-stripper-ignore-next + /// Check if the object class has a property `property_name` of the given `type_`. + fn has_property_with_type(&self, property_name: &str, type_: Type) -> bool { + self.property_type(property_name) + .is_some_and(|ptype| ptype == type_) } // rustdoc-stripper-ignore-next @@ -4262,17 +4268,16 @@ impl Interface { impl + IsInterface> Interface { // rustdoc-stripper-ignore-next - /// Check if this interface has a property `property_name` of the given `type_`. - /// - /// If no type is provided then only the existence of the property is checked. - pub fn has_property(&self, property_name: &str, type_: Option) -> bool { - let ptype = self.property_type(property_name); + /// Check if the interface has a property `property_name` of the given `type_`. + pub fn has_property(&self, property_name: &str) -> bool { + self.find_property(property_name).is_some() + } - match (ptype, type_) { - (None, _) => false, - (Some(_), None) => true, - (Some(ptype), Some(type_)) => ptype == type_, - } + // rustdoc-stripper-ignore-next + /// Check if the interface has a property `property_name` of the given `type_`. + pub fn has_property_with_type(&self, property_name: &str, type_: Type) -> bool { + self.property_type(property_name) + .is_some_and(|ptype| ptype == type_) } // rustdoc-stripper-ignore-next