Skip to content

Conversation

@cdbrkfxrpt
Copy link
Member

Following a convo with JG, I am planning to:

  • aim for Option-like semantics on MaybeMultiple;
  • aim for Vec-like semantics on Multiple;
  • be very deliberate about the semantics of both.

Specifically, this means that I want methods implemented on MaybeMultiple and Multiple to contribute to the reason why both of them exist, which is to make the semantics of a container that must contain at least two elements - Multiple - and an enumeration which can distinctively contain no elements, one element or multiple elements - MaybeMultiple - explicit in the type system. Implementing convenience conversion functions like From<Vec<T>> on MaybeMultiple, for example, does the opposite of this: it makes the conversion explicit, but in code it will always just be a call to .into() and thus not really visible. Making the call a MaybeMultiple::collapse_vec_into(v) for turning v: Vec into a MaybeMultiple seems a better choice. I hope to find others in the same vein, and I'd of course be thankful for second opinions.

@cdbrkfxrpt cdbrkfxrpt requested a review from fabitosh August 3, 2024 14:29
@cdbrkfxrpt cdbrkfxrpt self-assigned this Aug 3, 2024
@cdbrkfxrpt cdbrkfxrpt force-pushed the flrn/towards-good-semantics branch from de3f965 to a997a5d Compare August 3, 2024 14:58
@cdbrkfxrpt cdbrkfxrpt force-pushed the flrn/towards-good-semantics branch from a997a5d to ffda508 Compare August 3, 2024 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants