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
This means that person properties cannot be a float because f32/f64 do not implement Hash in Rust. Since wanting to store floats as person properties comes up a reasonable amount of times (i.e., time of last infection, natural history parameters potentially, maybe even per-person vaccine efficacy, etc.), we should have some general solution to this problem.
Here are two thoughts:
Declare whether the property will be indexed when defining the person property and accordingly require whether Hash be implemented on the type. Could also automatically call context.index_property(property) for such properties. Naturally enforces that float properties cannot be indexed, which feels like a good choice.
Internally store floats as some other type for which Hash is implemented. I can't really ever think of a case where our floats would be Nan, so potentially store floats as ordered_float::NotNan<f64> from crate ordered_float.
I think both solutions have their pros and cons, and I'm not yet sure which I prefer.
Side note: when making a person property that is a custom type, I have to derive a series of traits for the struct -- Debug, Clone, Copy, PartialEq, etc. Would it be possible to just do something like #[derive(IxaPersonProperty)]/is this a good idea, or would it be hiding important things from the user?
The text was updated successfully, but these errors were encountered:
Currently, the values associated with person properties must implement
Hash
(in addition to a series of other traits):ixa/src/people.rs
Line 397 in 8ae6321
This means that person properties cannot be a float because
f32/f64
do not implementHash
in Rust. Since wanting to store floats as person properties comes up a reasonable amount of times (i.e., time of last infection, natural history parameters potentially, maybe even per-person vaccine efficacy, etc.), we should have some general solution to this problem.Here are two thoughts:
Hash
be implemented on the type. Could also automatically callcontext.index_property(property)
for such properties. Naturally enforces that float properties cannot be indexed, which feels like a good choice.Hash
is implemented. I can't really ever think of a case where our floats would beNan
, so potentially store floats asordered_float::NotNan<f64>
from crateordered_float
.I think both solutions have their pros and cons, and I'm not yet sure which I prefer.
Side note: when making a person property that is a custom type, I have to derive a series of traits for the struct --
Debug
,Clone
,Copy
,PartialEq
, etc. Would it be possible to just do something like#[derive(IxaPersonProperty)]
/is this a good idea, or would it be hiding important things from the user?The text was updated successfully, but these errors were encountered: