Skip to content

Commit e9bad1a

Browse files
sdroegebilelmoussaoui
authored andcommitted
Replace Foo::from_instance(foo) with foo.imp()
1 parent 2d4ff01 commit e9bad1a

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

examples/virtual_methods/base_button/imp.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ pub struct BaseButton;
2929

3030
// Virtual method default implementation trampolines
3131
fn sync_method_default_trampoline(this: &BaseButtonInstance, extra_text: Option<String>) {
32-
BaseButton::from_instance(this).sync_method(this, extra_text)
32+
this.imp().sync_method(this, extra_text)
3333
}
3434

3535
fn async_method_default_trampoline(this: &BaseButtonInstance) -> PinnedFuture {
36-
BaseButton::from_instance(this).async_method(this)
36+
this.imp().async_method(this)
3737
}
3838

3939
pub(super) fn base_button_sync_method(this: &BaseButtonInstance, extra_text: Option<String>) {

examples/virtual_methods/base_button/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,14 @@ fn sync_method_trampoline<T>(this: &BaseButton, extra_text: Option<String>)
9595
where
9696
T: ObjectSubclass + BaseButtonImpl,
9797
{
98-
let imp = T::from_instance(this.dynamic_cast_ref::<T::Type>().unwrap());
98+
let imp = this.dynamic_cast_ref::<T::Type>().unwrap().imp();
9999
imp.sync_method(this, extra_text)
100100
}
101101

102102
fn async_method_trampoline<T>(this: &BaseButton) -> PinnedFuture
103103
where
104104
T: ObjectSubclass + BaseButtonImpl,
105105
{
106-
let imp = T::from_instance(this.dynamic_cast_ref::<T::Type>().unwrap());
106+
let imp = this.dynamic_cast_ref::<T::Type>().unwrap().imp();
107107
imp.async_method(this)
108108
}

gdk4/src/subclass/content_provider.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ impl<T: ContentProviderImpl> ContentProviderImplExt for T {
239239
Box::pin(gio::GioFuture::new(
240240
provider,
241241
move |obj, cancellable, send| {
242-
let imp = Self::from_instance(obj);
242+
let imp = obj.imp();
243243

244244
imp.parent_write_mime_type_async(
245245
&imp.instance(),

gtk4-macros/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ pub fn composite_template_derive(input: TokenStream) -> TokenStream {
221221
/// }
222222
/// #[template_callback]
223223
/// pub fn print_both_labels(&self) {
224-
/// let self_ = imp::MyWidget::from_instance(self);
224+
/// let self_ = self.imp();
225225
/// println!("{} {}", self_.label.label(), self_.button.label().unwrap().as_str());
226226
/// }
227227
/// }

gtk4/src/builder_rust_scope.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl BuilderRustScope {
5858
name: N,
5959
callback: F,
6060
) {
61-
imp::BuilderRustScope::from_instance(self)
61+
self.imp()
6262
.callbacks
6363
.borrow_mut()
6464
.insert(name.into(), Rc::new(callback));

0 commit comments

Comments
 (0)