Closed Yoric closed 8 years ago
this is a great idea, i was discussing with someone else in another PR some days ago how to make this method safer. will look into it
Also, I wonder about the memory-behavior of Element::set
with respect to value
. For example, if value
is a Box
(granted, probably not a good idea), since set
takes ownership, the Box
and its contents will be deallocated once we reach the end of the method, hence leaving a dangling pointer.
I'm not sure how to address this issue, or if it needs to be addressed at all.
Mmmh... It looks like glib-rs is doing something along these lines: http://gtk-rs.org/docs/glib/value/struct.Value.html
If I read the code (and my segfaults) correctly,
Element.set
takes an argument of any type and passes it tog_object_set
by simply coercing it to a pointer. That's a good way to segfault if I pass e.g. astr
.It might be possible to define a trait as follows
And implement
WithProperty
with the most common types.