Skip to content

Commit

Permalink
glib-macros: Make subclassable test actually do something at runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
sdroege committed May 23, 2024
1 parent 9765deb commit 470a75d
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions glib-macros/tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,12 +281,16 @@ fn subclassable() {
}

impl ObjectImpl for Foo {}

impl Foo {
pub(super) fn test(&self) {}
}
}

pub trait FooExt: IsA<Foo> + 'static {
fn test(&self) {
let _self = self.as_ref().downcast_ref::<Foo>().unwrap().imp();
unimplemented!()
let imp = self.as_ref().upcast_ref::<Foo>().imp();
imp.test();
}
}

Expand All @@ -296,6 +300,11 @@ fn subclassable() {
pub struct Foo(ObjectSubclass<imp::Foo>);
}
}

use foo::FooExt;

let obj = glib::Object::new::<foo::Foo>();
obj.test();
}

#[test]
Expand Down

0 comments on commit 470a75d

Please sign in to comment.