diff --git a/cairo/src/device.rs b/cairo/src/device.rs index 31436deeab9d..48a757a27ce3 100644 --- a/cairo/src/device.rs +++ b/cairo/src/device.rs @@ -159,7 +159,7 @@ impl Device { } #[doc(alias = "cairo_device_acquire")] - pub fn acquire(&self) -> Result { + pub fn acquire(&self) -> Result, Error> { unsafe { let status = ffi::cairo_device_acquire(self.to_raw_none()); status_to_result(status)?; diff --git a/cairo/src/image_surface.rs b/cairo/src/image_surface.rs index 1c50e00990ab..c6d3ddc7d097 100644 --- a/cairo/src/image_surface.rs +++ b/cairo/src/image_surface.rs @@ -84,7 +84,7 @@ impl ImageSurface { #[doc(alias = "cairo_image_surface_get_data")] #[doc(alias = "get_data")] - pub fn data(&mut self) -> Result { + pub fn data(&mut self) -> Result, BorrowError> { unsafe { if ffi::cairo_surface_get_reference_count(self.to_raw_none()) > 1 { return Err(BorrowError::NonExclusive); diff --git a/cairo/src/paths.rs b/cairo/src/paths.rs index f870d3165905..2f47a8c5a9c8 100644 --- a/cairo/src/paths.rs +++ b/cairo/src/paths.rs @@ -20,7 +20,7 @@ impl Path { Path(ptr::NonNull::new_unchecked(pointer)) } - pub fn iter(&self) -> PathSegments { + pub fn iter(&self) -> PathSegments<'_> { use std::slice; unsafe { diff --git a/gio/src/list_model.rs b/gio/src/list_model.rs index 83356a6f6ac1..803a9d3b42b7 100644 --- a/gio/src/list_model.rs +++ b/gio/src/list_model.rs @@ -26,7 +26,7 @@ pub trait ListModelExtManual: IsA + Sized { /// # Panics /// /// Panics if `T::static_type().is_a(self.item_type())` is not true. - fn iter>(&self) -> ListModelIter { + fn iter>(&self) -> ListModelIter<'_, LT> { assert!(self.item_type().is_a(LT::static_type())); let len = self.n_items(); diff --git a/gio/src/unix_socket_address.rs b/gio/src/unix_socket_address.rs index b0f347491bdb..4ad618887dc2 100644 --- a/gio/src/unix_socket_address.rs +++ b/gio/src/unix_socket_address.rs @@ -68,7 +68,7 @@ impl UnixSocketAddress { pub trait UnixSocketAddressExtManual: IsA + 'static { #[doc(alias = "g_unix_socket_address_get_path")] #[doc(alias = "get_path")] - fn path(&self) -> Option { + fn path(&self) -> Option> { use self::UnixSocketAddressPath::*; let path = unsafe { diff --git a/glib/src/collections/list.rs b/glib/src/collections/list.rs index b5e3cffbdab7..9ebb7ffd0d6f 100644 --- a/glib/src/collections/list.rs +++ b/glib/src/collections/list.rs @@ -101,14 +101,14 @@ impl List { // rustdoc-stripper-ignore-next /// Create a non-destructive iterator over the `List`. #[inline] - pub fn iter(&self) -> Iter { + pub fn iter(&self) -> Iter<'_, T> { Iter::new(self) } // rustdoc-stripper-ignore-next /// Create a non-destructive mutable iterator over the `List`. #[inline] - pub fn iter_mut(&mut self) -> IterMut { + pub fn iter_mut(&mut self) -> IterMut<'_, T> { IterMut::new(self) } diff --git a/glib/src/collections/slist.rs b/glib/src/collections/slist.rs index 70188ba1d71a..ad1ef90ba2a6 100644 --- a/glib/src/collections/slist.rs +++ b/glib/src/collections/slist.rs @@ -101,14 +101,14 @@ impl SList { // rustdoc-stripper-ignore-next /// Create a non-destructive iterator over the `SList`. #[inline] - pub fn iter(&self) -> Iter { + pub fn iter(&self) -> Iter<'_, T> { Iter::new(self) } // rustdoc-stripper-ignore-next /// Create a non-destructive mutable iterator over the `SList`. #[inline] - pub fn iter_mut(&mut self) -> IterMut { + pub fn iter_mut(&mut self) -> IterMut<'_, T> { IterMut::new(self) } diff --git a/glib/src/enums.rs b/glib/src/enums.rs index 642f4b179b34..f95a7852e912 100644 --- a/glib/src/enums.rs +++ b/glib/src/enums.rs @@ -748,14 +748,14 @@ impl FlagsClass { // rustdoc-stripper-ignore-next /// Returns a new `FlagsBuilder` for conveniently setting/unsetting flags /// and building a `Value`. - pub fn builder(&self) -> FlagsBuilder { + pub fn builder(&self) -> FlagsBuilder<'_> { FlagsBuilder::new(self) } // rustdoc-stripper-ignore-next /// Returns a new `FlagsBuilder` for conveniently setting/unsetting flags /// and building a `Value`. The `Value` is initialized with `value`. - pub fn builder_with_value(&self, value: Value) -> Option { + pub fn builder_with_value(&self, value: Value) -> Option> { if self.type_() != value.type_() { return None; } @@ -966,12 +966,12 @@ pub type FlagsValues = EnumerationValues; #[must_use = "The builder must be built to be used"] pub struct FlagsBuilder<'a>(&'a FlagsClass, Option); impl FlagsBuilder<'_> { - fn new(flags_class: &FlagsClass) -> FlagsBuilder { + fn new(flags_class: &FlagsClass) -> FlagsBuilder<'_> { let value = unsafe { Value::from_type_unchecked(flags_class.type_()) }; FlagsBuilder(flags_class, Some(value)) } - fn with_value(flags_class: &FlagsClass, value: Value) -> FlagsBuilder { + fn with_value(flags_class: &FlagsClass, value: Value) -> FlagsBuilder<'_> { FlagsBuilder(flags_class, Some(value)) } diff --git a/glib/src/main_context.rs b/glib/src/main_context.rs index 1213046bde55..5c98ead969f6 100644 --- a/glib/src/main_context.rs +++ b/glib/src/main_context.rs @@ -161,7 +161,7 @@ impl MainContext { /// /// This will fail if the main context is owned already by another thread. #[doc(alias = "g_main_context_acquire")] - pub fn acquire(&self) -> Result { + pub fn acquire(&self) -> Result, crate::BoolError> { unsafe { let ret: bool = from_glib(ffi::g_main_context_acquire(self.to_glib_none().0)); if ret { @@ -189,7 +189,7 @@ impl Drop for MainContextAcquireGuard<'_> { struct ThreadDefaultContext<'a>(&'a MainContext); impl ThreadDefaultContext<'_> { - fn new(ctx: &MainContext) -> ThreadDefaultContext { + fn new(ctx: &MainContext) -> ThreadDefaultContext<'_> { unsafe { ffi::g_main_context_push_thread_default(ctx.to_glib_none().0); } diff --git a/glib/src/object.rs b/glib/src/object.rs index 77b8b616d16e..22637311b59d 100644 --- a/glib/src/object.rs +++ b/glib/src/object.rs @@ -1688,7 +1688,7 @@ pub trait ObjectExt: ObjectType { /// /// `None` is returned if the object does not implement the interface `T`. #[doc(alias = "get_interface")] - fn interface(&self) -> Option>; + fn interface(&self) -> Option>; // rustdoc-stripper-ignore-next /// Sets the property `property_name` of the object to value `value`. @@ -2307,7 +2307,7 @@ impl ObjectExt for T { } #[inline] - fn interface(&self) -> Option> { + fn interface(&self) -> Option> { Interface::from_class(self.object_class()) } @@ -4037,7 +4037,7 @@ impl Class { /// Gets the parent class struct, if any. #[doc(alias = "g_type_class_peek_parent")] #[inline] - pub fn parent(&self) -> Option> { + pub fn parent(&self) -> Option> { unsafe { let ptr = gobject_ffi::g_type_class_peek_parent(&self.0 as *const _ as *mut _); if ptr.is_null() { @@ -4176,7 +4176,7 @@ impl Interface { /// /// This will return `None` if `klass` is not implementing `Self`. #[inline] - pub fn from_class(klass: &Class) -> Option> { + pub fn from_class(klass: &Class) -> Option> { if !klass.type_().is_a(T::static_type()) { return None; } @@ -4246,7 +4246,7 @@ impl Interface { /// interface. #[doc(alias = "g_type_interface_peek_parent")] #[inline] - pub fn parent(&self) -> Option> { + pub fn parent(&self) -> Option> { unsafe { let ptr = gobject_ffi::g_type_interface_peek_parent(&self.0 as *const _ as *mut _); if ptr.is_null() { diff --git a/glib/src/param_spec.rs b/glib/src/param_spec.rs index 1b6356498a7f..6a58efc4a58b 100644 --- a/glib/src/param_spec.rs +++ b/glib/src/param_spec.rs @@ -1129,14 +1129,14 @@ impl ParamSpecEnum { pub fn builder_with_default + IntoGlib>( name: &str, default_value: T, - ) -> ParamSpecEnumBuilder { + ) -> ParamSpecEnumBuilder<'_, T> { ParamSpecEnumBuilder::new(name, default_value) } #[doc(alias = "g_param_spec_enum")] pub fn builder + IntoGlib + Default>( name: &str, - ) -> ParamSpecEnumBuilder { + ) -> ParamSpecEnumBuilder<'_, T> { ParamSpecEnumBuilder::new(name, T::default()) } } @@ -1272,7 +1272,7 @@ impl ParamSpecFlags { #[doc(alias = "g_param_spec_flags")] pub fn builder + IntoGlib>( name: &str, - ) -> ParamSpecFlagsBuilder { + ) -> ParamSpecFlagsBuilder<'_, T> { ParamSpecFlagsBuilder::new(name) } } @@ -1442,7 +1442,7 @@ impl ParamSpecString { } #[doc(alias = "g_param_spec_string")] - pub fn builder(name: &str) -> ParamSpecStringBuilder { + pub fn builder(name: &str) -> ParamSpecStringBuilder<'_> { ParamSpecStringBuilder::new(name) } } @@ -1577,7 +1577,7 @@ impl ParamSpecBoxed { } #[doc(alias = "g_param_spec_boxed")] - pub fn builder(name: &str) -> ParamSpecBoxedBuilder { + pub fn builder(name: &str) -> ParamSpecBoxedBuilder<'_, T> { ParamSpecBoxedBuilder::new(name) } } @@ -1736,7 +1736,7 @@ impl ParamSpecValueArray { } #[doc(alias = "g_param_spec_value_array")] - pub fn builder(name: &str) -> ParamSpecValueArrayBuilder { + pub fn builder(name: &str) -> ParamSpecValueArrayBuilder<'_> { ParamSpecValueArrayBuilder::new(name) } } @@ -1833,7 +1833,7 @@ impl ParamSpecObject { } #[doc(alias = "g_param_spec_object")] - pub fn builder>(name: &str) -> ParamSpecObjectBuilder { + pub fn builder>(name: &str) -> ParamSpecObjectBuilder<'_, T> { ParamSpecObjectBuilder::new(name) } } diff --git a/glib/src/subclass/types.rs b/glib/src/subclass/types.rs index 90c5fd5e9321..bf2e0c6af17e 100644 --- a/glib/src/subclass/types.rs +++ b/glib/src/subclass/types.rs @@ -743,7 +743,7 @@ pub trait ObjectSubclassExt: ObjectSubclass { /// /// Shorter alias for `instance()`. #[doc(alias = "get_instance")] - fn obj(&self) -> crate::BorrowedObject; + fn obj(&self) -> crate::BorrowedObject<'_, Self::Type>; // rustdoc-stripper-ignore-next /// Returns the implementation from an instance. @@ -765,7 +765,7 @@ pub trait ObjectSubclassExt: ObjectSubclass { impl ObjectSubclassExt for T { #[inline] - fn obj(&self) -> crate::BorrowedObject { + fn obj(&self) -> crate::BorrowedObject<'_, Self::Type> { unsafe { let data = Self::type_data(); let type_ = data.as_ref().type_(); diff --git a/glib/src/value.rs b/glib/src/value.rs index 42cdd7b267a6..60136d082dd1 100644 --- a/glib/src/value.rs +++ b/glib/src/value.rs @@ -586,7 +586,9 @@ impl Value { // rustdoc-stripper-ignore-next /// Tries to get a value of an owned type `T`. #[inline] - pub fn get_owned(&self) -> Result::Checker as ValueTypeChecker>::Error> + pub fn get_owned( + &self, + ) -> Result>::Checker as ValueTypeChecker>::Error> where T: for<'b> FromValue<'b> + 'static, { diff --git a/glib/src/variant.rs b/glib/src/variant.rs index 0a9491ffa26a..edde050db596 100644 --- a/glib/src/variant.rs +++ b/glib/src/variant.rs @@ -841,7 +841,7 @@ impl Variant { /// } /// # Ok::<(), Box>(()) /// ``` - pub fn array_iter_str(&self) -> Result { + pub fn array_iter_str(&self) -> Result, VariantTypeMismatchError> { let child_ty = String::static_variant_type(); let actual_ty = self.type_(); let expected_ty = child_ty.as_array(); diff --git a/glib/src/variant_type.rs b/glib/src/variant_type.rs index 00c2c96e9382..aa7d30c9c85f 100644 --- a/glib/src/variant_type.rs +++ b/glib/src/variant_type.rs @@ -588,7 +588,7 @@ impl VariantTy { /// # Panics /// /// This function panics if not called with a tuple or dictionary entry type. - pub fn tuple_types(&self) -> VariantTyIterator { + pub fn tuple_types(&self) -> VariantTyIterator<'_> { VariantTyIterator::new(self).expect("VariantTy does not represent a tuple") } diff --git a/pango/Gir.toml b/pango/Gir.toml index 2998e9d05da8..00e195c2789d 100644 --- a/pango/Gir.toml +++ b/pango/Gir.toml @@ -168,6 +168,9 @@ status = "generate" name = "from_string" [object.function.return] nullable_return_is_error = "Can't parse AttrList" + [[object.function]] + name = "get_iterator" + manual = true [[object]] name = "Pango.AttrType" diff --git a/pango/src/attr_list.rs b/pango/src/attr_list.rs index f497dd71573f..e47115be123d 100644 --- a/pango/src/attr_list.rs +++ b/pango/src/attr_list.rs @@ -4,7 +4,7 @@ use std::mem; use glib::translate::*; -use crate::{ffi, AttrList, Attribute}; +use crate::{ffi, AttrIterator, AttrList, Attribute}; impl AttrList { #[doc(alias = "pango_attr_list_change")] @@ -45,6 +45,12 @@ impl AttrList { mem::forget(attr); //As attr transferred fully } } + + #[doc(alias = "pango_attr_list_get_iterator")] + #[doc(alias = "get_iterator")] + pub fn iterator(&self) -> AttrIterator<'_> { + unsafe { from_glib_full(ffi::pango_attr_list_get_iterator(self.to_glib_none().0)) } + } } #[cfg(feature = "v1_46")] diff --git a/pango/src/auto/attr_list.rs b/pango/src/auto/attr_list.rs index e366296904d8..ccf897a7ab47 100644 --- a/pango/src/auto/attr_list.rs +++ b/pango/src/auto/attr_list.rs @@ -2,7 +2,7 @@ // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT -use crate::{ffi, AttrIterator, Attribute}; +use crate::{ffi, Attribute}; use glib::translate::*; glib::wrapper! { @@ -63,12 +63,6 @@ impl AttrList { } } - #[doc(alias = "pango_attr_list_get_iterator")] - #[doc(alias = "get_iterator")] - pub fn iterator(&self) -> AttrIterator { - unsafe { from_glib_full(ffi::pango_attr_list_get_iterator(self.to_glib_none().0)) } - } - #[doc(alias = "pango_attr_list_splice")] pub fn splice(&self, other: &AttrList, pos: i32, len: i32) { unsafe {