Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: explicit conversion method implementations #1

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

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.

1 participant