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
users of this tend to have to write foo.get_product().unwrap_or(XXX) where XXX is the ONE value for T.
maybe it would be better to require T to implement something like a HasUnit trait that provides a T::ONE value as a constant, to be returned instead of the None? i don't know if the None return with the unwrap_or is at all guaranteed to be optimized out (are there separate compilation issues?) but even ignoring that I would think not having to do the unwrap_or at every call site would make the using code (slightly) more readable.
is there a case to be made for detecting when the tree of products is empty and handling that differently via the None return to distinguish the case where a non-empty tree might return the 1 value?
currently this has undocumented semantics wrt out of range index values yielding the product of all values, though maybe arguably this is covered by 'except the one at the given index' because there aren't any values at the index? the test verifies this behavior -- and i think we probably should just test use the size (for InternalNode) to panic when out of range.
The text was updated successfully, but these errors were encountered:
bennetyee
changed the title
require a HasUnit trait?
nit: require a HasUnit trait?
Sep 27, 2024
oasis-core/secret-sharing/src/poly/lagrange/multiplier.rs
Line 69 in 7bf2296
users of this tend to have to write
foo.get_product().unwrap_or(XXX)
whereXXX
is the ONE value forT
.maybe it would be better to require
T
to implement something like aHasUnit
trait that provides aT::ONE
value as a constant, to be returned instead of theNone
? i don't know if theNone
return with theunwrap_or
is at all guaranteed to be optimized out (are there separate compilation issues?) but even ignoring that I would think not having to do theunwrap_or
at every call site would make the using code (slightly) more readable.is there a case to be made for detecting when the tree of products is empty and handling that differently via the
None
return to distinguish the case where a non-empty tree might return the 1 value?currently this has undocumented semantics wrt out of range index values yielding the product of all values, though maybe arguably this is covered by 'except the one at the given index' because there aren't any values at the index? the test verifies this behavior -- and i think we probably should just test use the
size
(forInternalNode
) to panic when out of range.The text was updated successfully, but these errors were encountered: