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

Replace ByteString(ByteArray) constructor with ByteArray.toByteString() #260

Open
joffrey-bion opened this issue Feb 13, 2024 · 0 comments

Comments

@joffrey-bion
Copy link

joffrey-bion commented Feb 13, 2024

This current "safe" constructor doesn't feel right. It has the following drawbacks:

  • the constructor syntax implies "wrapping" (as if the array is used as a property), but what actually happens is a copy
  • it's hard to discover: when I want to turn a ByteString into a ByteArray, the completion helps me find the toByteArray() extension. When I look for the inverse operation, I can't find it via completion
  • it's not symmetrical with the ByteString.toByteArray() counterpart
  • it's not easily composable: nullableByteString?.toByteArray() is nice, while nullableByteArray?.let { ByteString(it) } is not nice

Adding a ByteArray.toByteString() extension would solve all of these.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants