Skip to content

Commit a65c21f

Browse files
felinirabilelmoussaoui
authored andcommitted
Add additional type bounds to Impl traits
1 parent adf5b72 commit a65c21f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+164
-442
lines changed

Cargo.lock

Lines changed: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/virtual_methods/base_button/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl<O: IsA<BaseButton>> BaseButtonExt for O {}
6060
/// implement.
6161
///
6262
/// See `derived_button/imp.rs` for how to override virtual methods.
63-
pub trait BaseButtonImpl: ButtonImpl {
63+
pub trait BaseButtonImpl: ButtonImpl + ObjectSubclass<Type: IsA<BaseButton>> {
6464
/// Default implementation of a virtual method.
6565
///
6666
/// This always calls into the implementation of the parent class so that if

gdk4/src/subclass/content_provider.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use glib::{translate::*, Value};
99

1010
use crate::{ffi, prelude::*, subclass::prelude::*, Clipboard, ContentFormats, ContentProvider};
1111

12-
pub trait ContentProviderImpl: ContentProviderImplExt + ObjectImpl {
12+
pub trait ContentProviderImpl: ObjectImpl + ObjectSubclass<Type: IsA<ContentProvider>> {
1313
fn content_changed(&self) {
1414
self.parent_content_changed()
1515
}
@@ -44,12 +44,7 @@ pub trait ContentProviderImpl: ContentProviderImplExt + ObjectImpl {
4444
}
4545
}
4646

47-
mod sealed {
48-
pub trait Sealed {}
49-
impl<T: super::ContentProviderImplExt> Sealed for T {}
50-
}
51-
52-
pub trait ContentProviderImplExt: sealed::Sealed + ObjectSubclass {
47+
pub trait ContentProviderImplExt: ContentProviderImpl {
5348
fn parent_content_changed(&self) {
5449
unsafe {
5550
let data = Self::type_data();

gdk4/src/subclass/paintable.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use glib::translate::*;
88

99
use crate::{ffi, prelude::*, subclass::prelude::*, Paintable, PaintableFlags, Snapshot};
1010

11-
pub trait PaintableImpl: PaintableImplExt + ObjectImpl {
11+
pub trait PaintableImpl: ObjectImpl + ObjectSubclass<Type: IsA<Paintable>> {
1212
#[doc(alias = "get_current_image")]
1313
fn current_image(&self) -> Paintable {
1414
self.parent_current_image()
@@ -37,12 +37,7 @@ pub trait PaintableImpl: PaintableImplExt + ObjectImpl {
3737
fn snapshot(&self, snapshot: &Snapshot, width: f64, height: f64);
3838
}
3939

40-
mod sealed {
41-
pub trait Sealed {}
42-
impl<T: super::PaintableImplExt> Sealed for T {}
43-
}
44-
45-
pub trait PaintableImplExt: sealed::Sealed + ObjectSubclass {
40+
pub trait PaintableImplExt: PaintableImpl {
4641
fn parent_current_image(&self) -> Paintable {
4742
unsafe {
4843
let type_data = Self::type_data();

gtk4/src/subclass/accessible.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::{
1212
ffi, prelude::*, subclass::prelude::*, ATContext, Accessible, AccessiblePlatformState,
1313
};
1414

15-
pub trait AccessibleImpl: ObjectImpl {
15+
pub trait AccessibleImpl: ObjectImpl + ObjectSubclass<Type: IsA<Accessible>> {
1616
#[doc(alias = "get_platform_state")]
1717
fn platform_state(&self, state: AccessiblePlatformState) -> bool {
1818
self.parent_platform_state(state)
@@ -44,12 +44,7 @@ pub trait AccessibleImpl: ObjectImpl {
4444
}
4545
}
4646

47-
mod sealed {
48-
pub trait Sealed {}
49-
impl<T: super::AccessibleImplExt> Sealed for T {}
50-
}
51-
52-
pub trait AccessibleImplExt: sealed::Sealed + ObjectSubclass {
47+
pub trait AccessibleImplExt: AccessibleImpl {
5348
fn parent_platform_state(&self, state: AccessiblePlatformState) -> bool {
5449
unsafe {
5550
let type_data = Self::type_data();

gtk4/src/subclass/accessible_range.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,13 @@ use glib::translate::*;
88

99
use crate::{ffi, prelude::*, subclass::prelude::*, AccessibleRange};
1010

11-
pub trait AccessibleRangeImpl: WidgetImpl {
11+
pub trait AccessibleRangeImpl: AccessibleImpl + ObjectSubclass<Type: IsA<AccessibleRange>> {
1212
fn set_current_value(&self, value: f64) -> bool {
1313
self.parent_set_current_value(value)
1414
}
1515
}
1616

17-
mod sealed {
18-
pub trait Sealed {}
19-
impl<T: super::AccessibleRangeImplExt> Sealed for T {}
20-
}
21-
22-
pub trait AccessibleRangeImplExt: sealed::Sealed + ObjectSubclass {
17+
pub trait AccessibleRangeImplExt: AccessibleRangeImpl {
2318
// Returns true if the operation was performed, false otherwise
2419
fn parent_set_current_value(&self, value: f64) -> bool {
2520
unsafe {

gtk4/src/subclass/actionable.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use glib::{translate::*, GString, Variant};
88

99
use crate::{ffi, prelude::*, subclass::prelude::*, Actionable};
1010

11-
pub trait ActionableImpl: WidgetImpl {
11+
pub trait ActionableImpl: WidgetImpl + ObjectSubclass<Type: IsA<Actionable>> {
1212
#[doc(alias = "get_action_name")]
1313
fn action_name(&self) -> Option<GString>;
1414
#[doc(alias = "get_action_target_value")]
@@ -17,12 +17,7 @@ pub trait ActionableImpl: WidgetImpl {
1717
fn set_action_target_value(&self, value: Option<&Variant>);
1818
}
1919

20-
mod sealed {
21-
pub trait Sealed {}
22-
impl<T: super::ActionableImplExt> Sealed for T {}
23-
}
24-
25-
pub trait ActionableImplExt: sealed::Sealed + ObjectSubclass {
20+
pub trait ActionableImplExt: ActionableImpl {
2621
fn parent_action_name(&self) -> Option<GString> {
2722
unsafe {
2823
let type_data = Self::type_data();

gtk4/src/subclass/adjustment.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use glib::translate::*;
77

88
use crate::{ffi, prelude::*, subclass::prelude::*, Adjustment};
99

10-
pub trait AdjustmentImpl: AdjustmentImplExt + ObjectImpl {
10+
pub trait AdjustmentImpl: ObjectImpl + ObjectSubclass<Type: IsA<Adjustment>> {
1111
fn changed(&self) {
1212
self.parent_changed()
1313
}
@@ -17,12 +17,7 @@ pub trait AdjustmentImpl: AdjustmentImplExt + ObjectImpl {
1717
}
1818
}
1919

20-
mod sealed {
21-
pub trait Sealed {}
22-
impl<T: super::AdjustmentImplExt> Sealed for T {}
23-
}
24-
25-
pub trait AdjustmentImplExt: sealed::Sealed + ObjectSubclass {
20+
pub trait AdjustmentImplExt: AdjustmentImpl {
2621
fn parent_changed(&self) {
2722
unsafe {
2823
let data = Self::type_data();

gtk4/src/subclass/application.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use glib::translate::*;
77

88
use crate::{ffi, prelude::*, subclass::prelude::*, Application, Window};
99

10-
pub trait GtkApplicationImpl: GtkApplicationImplExt + ApplicationImpl {
10+
pub trait GtkApplicationImpl: ApplicationImpl + ObjectSubclass<Type: IsA<Application>> {
1111
fn window_added(&self, window: &Window) {
1212
self.parent_window_added(window)
1313
}
@@ -17,12 +17,7 @@ pub trait GtkApplicationImpl: GtkApplicationImplExt + ApplicationImpl {
1717
}
1818
}
1919

20-
mod sealed {
21-
pub trait Sealed {}
22-
impl<T: super::GtkApplicationImplExt> Sealed for T {}
23-
}
24-
25-
pub trait GtkApplicationImplExt: sealed::Sealed + ObjectSubclass {
20+
pub trait GtkApplicationImplExt: GtkApplicationImpl {
2621
fn parent_window_added(&self, window: &Window) {
2722
unsafe {
2823
let data = Self::type_data();

gtk4/src/subclass/application_window.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44
//! Traits intended for subclassing
55
//! [`ApplicationWindow`](crate::ApplicationWindow).
66
7-
use crate::{subclass::prelude::*, ApplicationWindow};
7+
use crate::{prelude::*, subclass::prelude::*, ApplicationWindow};
88

9-
pub trait ApplicationWindowImpl: WindowImpl + 'static {}
9+
pub trait ApplicationWindowImpl:
10+
WindowImpl + ObjectSubclass<Type: IsA<ApplicationWindow>> + 'static
11+
{
12+
}
1013

1114
unsafe impl<T: ApplicationWindowImpl> IsSubclassable<T> for ApplicationWindow {}

gtk4/src/subclass/box_.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
// rustdoc-stripper-ignore-next
44
//! Traits intended for subclassing [`Box`](crate::Box).
55
6-
use crate::{subclass::prelude::*, Box};
6+
use crate::{prelude::*, subclass::prelude::*, Box};
77

8-
pub trait BoxImpl: WidgetImpl {}
8+
pub trait BoxImpl: WidgetImpl + ObjectSubclass<Type: IsA<Box>> {}
99

1010
unsafe impl<T: BoxImpl> IsSubclassable<T> for Box {}

gtk4/src/subclass/buildable.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use glib::{translate::*, GString, Object, Quark, Value};
1010
use super::PtrHolder;
1111
use crate::{ffi, prelude::*, subclass::prelude::*, Buildable, Builder};
1212

13-
pub trait BuildableImpl: ObjectImpl {
13+
pub trait BuildableImpl: ObjectImpl + ObjectSubclass<Type: IsA<Buildable>> {
1414
fn set_id(&self, id: &str) {
1515
self.parent_set_id(id)
1616
}
@@ -59,12 +59,7 @@ pub trait BuildableImpl: ObjectImpl {
5959
// );
6060
}
6161

62-
mod sealed {
63-
pub trait Sealed {}
64-
impl<T: super::BuildableImplExt> Sealed for T {}
65-
}
66-
67-
pub trait BuildableImplExt: sealed::Sealed + ObjectSubclass {
62+
pub trait BuildableImplExt: BuildableImpl {
6863
fn parent_set_id(&self, id: &str) {
6964
unsafe {
7065
let type_data = Self::type_data();

gtk4/src/subclass/builder_scope.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ use crate::{
1111
BuilderScope,
1212
};
1313

14-
pub trait BuilderCScopeImpl: BuilderScopeImpl {}
14+
pub trait BuilderCScopeImpl: BuilderScopeImpl + ObjectSubclass<Type: IsA<BuilderCScope>> {}
1515

1616
unsafe impl<T: BuilderCScopeImpl> IsSubclassable<T> for BuilderCScope {}
1717

18-
pub trait BuilderScopeImpl: ObjectImpl {
18+
pub trait BuilderScopeImpl: ObjectImpl + ObjectSubclass<Type: IsA<BuilderScope>> {
1919
#[doc(alias = "get_type_from_name")]
2020
fn type_from_name(&self, builder: &Builder, type_name: &str) -> glib::Type {
2121
self.parent_type_from_name(builder, type_name)
@@ -35,12 +35,7 @@ pub trait BuilderScopeImpl: ObjectImpl {
3535
) -> Result<glib::Closure, glib::Error>;
3636
}
3737

38-
mod sealed {
39-
pub trait Sealed {}
40-
impl<T: super::BuilderScopeImplExt> Sealed for T {}
41-
}
42-
43-
pub trait BuilderScopeImplExt: sealed::Sealed + ObjectSubclass {
38+
pub trait BuilderScopeImplExt: BuilderScopeImpl {
4439
fn parent_type_from_name(&self, builder: &Builder, type_name: &str) -> glib::Type {
4540
unsafe {
4641
let type_data = Self::type_data();

0 commit comments

Comments
 (0)