You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It maps one-to-one to f64 (0. maps to the first item, others map to the second item). I'd like to use it with the properties macro. For GObject it should appear as an f64 property.
Currently this seems to require implementing HasParamSpec, ToValue, From<ScaleRequest> for Value (for some reason?) and FromValue, the last of which requires unsafe code:
Would be great if this could be representable without unsafe code with some kind of pair of From<f64> for T + From<T> for f64.
It's also worth noting that I could instead implement Property with Value = f64 and custom get and set returning f64. However, that would result in my Rust type having getter and setter working with f64 instead of the real type, which is not as nice.
The text was updated successfully, but these errors were encountered:
I think what would be nice to have is something like a transform = from attribute on the macro, which would be used together with type. Then you could in your case do type = f64, transform = from and provide From impls in both directions for your enum.
We might want to add other ways of transformation later, not sure. If you can't think of anything else then maybe just a from attribute would be sufficient.
Instead of requiring transform = from, the PR I just pushed always calls From::from. That enables supporting other types which don't implement FromValue, as ThreadGuard.
I have a newtype over f64:
It maps one-to-one to f64 (0. maps to the first item, others map to the second item). I'd like to use it with the properties macro. For GObject it should appear as an f64 property.
Currently this seems to require implementing
HasParamSpec
,ToValue
,From<ScaleRequest> for Value
(for some reason?) andFromValue
, the last of which requires unsafe code:Would be great if this could be representable without unsafe code with some kind of pair of
From<f64> for T
+From<T> for f64
.It's also worth noting that I could instead implement
Property
withValue = f64
and custom get and set returningf64
. However, that would result in my Rust type having getter and setter working withf64
instead of the real type, which is not as nice.The text was updated successfully, but these errors were encountered: