From d43ffc33a2fde20507ed5d125a0b5a9b1dad6184 Mon Sep 17 00:00:00 2001 From: ranfdev Date: Thu, 1 Dec 2022 21:26:51 +0100 Subject: [PATCH] Add example for --- glib/src/object.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/glib/src/object.rs b/glib/src/object.rs index 180dbe3b128f..175a193f0b30 100644 --- a/glib/src/object.rs +++ b/glib/src/object.rs @@ -290,6 +290,17 @@ impl Cast for T {} // rustdoc-stripper-ignore-next /// Convenience trait mirroring `Cast`, implemented on `Option` types. +/// +/// # Example +/// ```ignore +/// let widget: Option = list_item.child(); +/// +/// // Without using `CastNone` +/// let label: gtk::Label = widget.unwrap().downcast().unwrap(); +/// +/// // Using `CastNone` we can avoid the first `unwrap()` call +/// let label: gtk::Label = widget.downcast().unwrap(); +/// ```` pub trait CastNone: Sized { type Inner; fn downcast(self) -> Result