tinystr icon indicating copy to clipboard operation
tinystr copied to clipboard

Empty String?

Open BartMassey opened this issue 6 years ago • 4 comments

I am not quite following the argument that prevents the empty string from being a thing? I get that there's probably a reason, but I didn't spot it in a quick scan of the source.

BartMassey avatar Aug 11 '19 01:08 BartMassey

The original motivation is mostly that they types they were replacing (in fluent-locale-rs) was Option<String>. And tags in locales can never be empty strings. So the idea was that by using a NonZero as the backing store, we would be able to preserve those semantics while also being very efficient.

It would certainly be possible to support a variant that allowed the empty string but would not be as efficient when wrapped in an Option. It didn't meet the needs of fluent so it wasn't included. I hope this clarifies.

raphlinus avatar Aug 12 '19 19:08 raphlinus

It does. I am thinking seriously about taking my current code, now that the files are merged, and changing it from macro-based to trait-based. At that point adding the corresponding nullable types would be almost free. I'll poke at it and let you know.

BartMassey avatar Aug 13 '19 06:08 BartMassey

@bartmassey - do you think I should wait for your pr or cut out a release for tinystr16 already?

zbraniecki avatar Aug 14 '19 17:08 zbraniecki

Don't feel strongly, but I think you might as well cut a release unless it's a lot of trouble? I don't expect the API to change in a backward-incompatible way at this point, but I think that's true of this change as well?

BartMassey avatar Aug 15 '19 01:08 BartMassey

We now allow empty strings.

Manishearth avatar Nov 08 '22 18:11 Manishearth