-
-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Class structs should be Copy #1381
Comments
Also the instance struct |
The goal here would be the following, and making it actually compile, which requires adding bounds and derive diff --git a/glib/src/subclass/types.rs b/glib/src/subclass/types.rs
index d4547986ce4..18697626d8f 100644
--- a/glib/src/subclass/types.rs
+++ b/glib/src/subclass/types.rs
@@ -47,7 +47,10 @@ struct PrivateStruct<T: ObjectSubclass> {
/// required in the instance struct.
///
/// [`basic::InstanceStruct`]: ../basic/struct.InstanceStruct.html
-pub unsafe trait InstanceStruct: Sized + 'static {
+pub unsafe trait InstanceStruct: Sized + 'static
+where
+ Self: Copy,
+{
// rustdoc-stripper-ignore-next
/// Corresponding object subclass type for this instance struct.
type Type: ObjectSubclass;
@@ -175,7 +178,10 @@ impl<T: ObjectSubclassIs<Subclass = S>, S: ObjectSubclass<Type = Self>> ObjectSu
/// required in the class struct, e.g. for declaring new virtual methods.
///
/// [`basic::ClassStruct`]: ../basic/struct.ClassStruct.html
-pub unsafe trait ClassStruct: Sized + 'static {
+pub unsafe trait ClassStruct: Sized + 'static
+where
+ Self: Copy,
+{
// rustdoc-stripper-ignore-next
/// Corresponding object subclass type for this class struct.
type Type: ObjectSubclass; |
We should also consider not copying the interface struct ourselves here but simply taking the pointer of it that is already stored inside GObject. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Class structs should have a bound on
Copy
, because that's what GObject is doing internally. If we were exposingbase_init
this could be avoided.See #1378 (comment)_
The text was updated successfully, but these errors were encountered: