Skip to content

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

Open
@joffrey-bion

Description

@joffrey-bion

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions