Skip to content

Commit 19f6a9c

Browse files
committed
handle smart pointers trasparently
1 parent d6d1b4c commit 19f6a9c

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

glib-macros/tests/props.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ fn props() {
2323
}
2424

2525
pub mod imp {
26+
use std::rc::Rc;
27+
2628
use super::*;
2729

2830
#[derive(Props, Default)]
@@ -53,6 +55,8 @@ fn props() {
5355
boxed: RefCell<SimpleBoxedString>,
5456
#[prop(get, set)]
5557
optional: RefCell<Option<String>>,
58+
#[prop(get, set)]
59+
smart_pointer: Rc<RefCell<String>>,
5660
}
5761

5862
#[glib::object_subclass]

glib/src/props.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,17 @@ impl<T: Property> Property for RwLock<T> {
4848
type Value = T;
4949
type ParamSpec = T::ParamSpec;
5050
}
51-
impl<T: Property> Property for Rc<T> {
51+
impl<T: Property> Property for OnceCell<T> {
5252
type Value = T;
5353
type ParamSpec = T::ParamSpec;
5454
}
55-
impl<T: Property> Property for Arc<T> {
56-
type Value = T;
55+
// Handle smart pointers trasparently
56+
impl<T: Property> Property for Rc<T> {
57+
type Value = T::Value;
5758
type ParamSpec = T::ParamSpec;
5859
}
59-
impl<T: Property> Property for OnceCell<T> {
60-
type Value = T;
60+
impl<T: Property> Property for Arc<T> {
61+
type Value = T::Value;
6162
type ParamSpec = T::ParamSpec;
6263
}
6364

0 commit comments

Comments
 (0)