diff --git a/book/listings/gobject_properties/4/custom_button/imp.rs b/book/listings/gobject_properties/4/custom_button/imp.rs index 31bc01d4fa3b..af5e26785faf 100644 --- a/book/listings/gobject_properties/4/custom_button/imp.rs +++ b/book/listings/gobject_properties/4/custom_button/imp.rs @@ -80,7 +80,7 @@ impl WidgetImpl for CustomButton {} // Trait shared by all buttons impl ButtonImpl for CustomButton { fn clicked(&self, button: &Self::Type) { - let incremented_number = self.number.borrow().clone() + 1; + let incremented_number = *self.number.borrow() + 1; button.set_property("number", &incremented_number).unwrap(); button.set_label(&self.number.borrow().to_string()) } diff --git a/book/listings/gobject_properties/4/custom_button/mod.rs b/book/listings/gobject_properties/4/custom_button/mod.rs index 5a0569ae4a16..876e81d6839f 100644 --- a/book/listings/gobject_properties/4/custom_button/mod.rs +++ b/book/listings/gobject_properties/4/custom_button/mod.rs @@ -13,3 +13,9 @@ impl CustomButton { Object::new(&[]).expect("Failed to create Button") } } + +impl Default for CustomButton { + fn default() -> Self { + CustomButton::new() + } +} diff --git a/book/listings/gobject_signals/3/custom_button/mod.rs b/book/listings/gobject_signals/3/custom_button/mod.rs index cd261421e0c2..b7df3d1fa71e 100644 --- a/book/listings/gobject_signals/3/custom_button/mod.rs +++ b/book/listings/gobject_signals/3/custom_button/mod.rs @@ -12,3 +12,9 @@ impl CustomButton { glib::Object::new(&[]).expect("Failed to create Button") } } + +impl Default for CustomButton { + fn default() -> Self { + CustomButton::new() + } +} diff --git a/book/listings/gobject_subclassing/1/custom_button/mod.rs b/book/listings/gobject_subclassing/1/custom_button/mod.rs index 8cd26311a338..6f337d78b74e 100644 --- a/book/listings/gobject_subclassing/1/custom_button/mod.rs +++ b/book/listings/gobject_subclassing/1/custom_button/mod.rs @@ -16,3 +16,9 @@ impl CustomButton { glib::Object::new(&[("label", &label)]).expect("Failed to create Button") } } + +impl Default for CustomButton { + fn default() -> Self { + CustomButton::new() + } +} diff --git a/book/listings/gobject_subclassing/2/custom_button/mod.rs b/book/listings/gobject_subclassing/2/custom_button/mod.rs index cd261421e0c2..b7df3d1fa71e 100644 --- a/book/listings/gobject_subclassing/2/custom_button/mod.rs +++ b/book/listings/gobject_subclassing/2/custom_button/mod.rs @@ -12,3 +12,9 @@ impl CustomButton { glib::Object::new(&[]).expect("Failed to create Button") } } + +impl Default for CustomButton { + fn default() -> Self { + CustomButton::new() + } +}