Skip to content

Commit 6f90794

Browse files
committed
examples: remove unused code
1 parent 83af810 commit 6f90794

File tree

1 file changed

+9
-18
lines changed
  • examples/virtual_methods/base_button

1 file changed

+9
-18
lines changed

examples/virtual_methods/base_button/imp.rs

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ pub type PinnedFuture = Pin<Box<dyn Future<Output = Result<(), Error>> + 'static
1414
#[repr(C)]
1515
pub struct BaseButtonClass {
1616
pub parent_class: gtk::ffi::GtkButtonClass,
17+
// If these functions are meant to be called from C, you need to make these functions
18+
// `extern "C"` & use FFI-safe types (usually raw pointers).
1719
pub sync_method: Option<unsafe fn(&BaseButtonInstance, extra_text: Option<String>)>,
1820
pub async_method: Option<unsafe fn(&BaseButtonInstance) -> PinnedFuture>,
1921
}
@@ -22,38 +24,27 @@ unsafe impl ClassStruct for BaseButtonClass {
2224
type Type = BaseButton;
2325
}
2426

25-
impl std::ops::Deref for BaseButtonClass {
26-
type Target = glib::Class<glib::Object>;
27-
28-
fn deref(&self) -> &Self::Target {
29-
unsafe { &*(self as *const _ as *const Self::Target) }
30-
}
31-
}
32-
33-
impl std::ops::DerefMut for BaseButtonClass {
34-
fn deref_mut(&mut self) -> &mut glib::Class<glib::Object> {
35-
unsafe { &mut *(self as *mut _ as *mut glib::Class<glib::Object>) }
36-
}
37-
}
38-
3927
#[derive(Debug, Default)]
4028
pub struct BaseButton;
4129

4230
// Virtual method default implementation trampolines
43-
unsafe fn sync_method_default_trampoline(this: &BaseButtonInstance, extra_text: Option<String>) {
31+
fn sync_method_default_trampoline(this: &BaseButtonInstance, extra_text: Option<String>) {
4432
BaseButton::from_instance(this).sync_method(this, extra_text)
4533
}
4634

47-
unsafe fn async_method_default_trampoline(this: &BaseButtonInstance) -> PinnedFuture {
35+
fn async_method_default_trampoline(this: &BaseButtonInstance) -> PinnedFuture {
4836
BaseButton::from_instance(this).async_method(this)
4937
}
5038

51-
pub unsafe fn base_button_sync_method(this: &BaseButtonInstance, extra_text: Option<String>) {
39+
pub(super) unsafe fn base_button_sync_method(
40+
this: &BaseButtonInstance,
41+
extra_text: Option<String>,
42+
) {
5243
let klass = &*(this.class() as *const _ as *const BaseButtonClass);
5344
(klass.sync_method.unwrap())(this, extra_text)
5445
}
5546

56-
pub unsafe fn base_button_async_method(this: &BaseButtonInstance) -> PinnedFuture {
47+
pub(super) unsafe fn base_button_async_method(this: &BaseButtonInstance) -> PinnedFuture {
5748
let klass = &*(this.class() as *const _ as *const BaseButtonClass);
5849
klass.async_method.unwrap()(this)
5950
}

0 commit comments

Comments
 (0)