When I create an enum type and use the glib::Enum derive proc-macro, I get a compiler error from within the glib::Properties derive proc-macro when trying to use my enum as a property. The compiler error:
error[E0061]: this function takes 2 arguments but 1 argument was supplied
--> src/main.rs:28:5
|
25 | #[derive(glib::Properties)]
| ---------------- an argument of type `TestType` is missing
...
28 | #[property(get, set)]
| ^^^^^^^^^^^^^^^^^^^^^
In the code below, if I change the_test_type to be a RefCell<i32> or a RefCell<TestTypeStruct>, it works:
use gtk4::prelude::*;
use gtk4::subclass::prelude::*;
use std::cell::RefCell;
use gtk4::glib::{
self,
subclass::{object::ObjectImpl, types::ObjectSubclass},
};
// Does NOT work when `the_test_type` is RefCell<TestType>
#[derive(Clone, Copy, glib::Enum)]
#[enum_type(name = "TestType")]
enum TestType {
One,
Two,
}
// Works when `the_test_type` is RefCell<TestTypeStruct>
#[derive(Clone, Copy, glib::Boxed)]
#[boxed_type(name = "TestTypeStruct")]
pub struct TestTypeStruct {
value: i32,
}
#[derive(glib::Properties)]
#[properties(wrapper_type = wrapper::Test)]
pub struct Test {
#[property(get, set)]
pub the_test_type: RefCell<TestType>,
}
impl Default for Test {
fn default() -> Self {
Test {
the_test_type: RefCell::new(TestType::One),
}
}
}
#[glib::derived_properties]
impl ObjectImpl for Test {}
#[glib::object_subclass]
impl ObjectSubclass for Test {
const NAME: &'static str = "Test";
type Type = wrapper::Test;
type ParentType = glib::Object;
}
mod wrapper {
use gtk4::glib;
glib::wrapper! {
pub struct Test(ObjectSubclass<super::Test>);
}
}
I took a look through the output of cargo expand, but I couldn't determine the function that the error is referring to. Thank you for your time!
When I create an
enum
type and use theglib::Enum
derive proc-macro, I get a compiler error from within theglib::Properties
derive proc-macro when trying to use my enum as a property. The compiler error:In the code below, if I change
the_test_type
to be aRefCell<i32>
or aRefCell<TestTypeStruct>
, it works:I took a look through the output of
cargo expand
, but I couldn't determine the function that the error is referring to. Thank you for your time!