unicode-rs / unicode-normalization

Unicode Normalization forms according to UAX#15 rules
https://unicode-rs.github.io/unicode-normalization
Other
160 stars 42 forks source link

Support #![no_std] without liballoc #58

Open tarcieri opened 4 years ago

tarcieri commented 4 years ago

I'd like to be able to use is_nfc_quick()/is_nfd_quick() in a context where liballoc isn't available.

It looks like the only thing linking liballoc right now is tinyvec. Would it be possible to make tinyvec into an optional dependency?

Manishearth commented 4 years ago

tinyvec is necessary because theoretically decompositions and compositions can map to an unbounded number of decomposed # code points. There's probably a small practical limit in what the composition data allows though

tarcieri commented 4 years ago

There's probably a small practical limit in what the composition data allows though

Perhaps tinyvec::ArrayVec could work? (or could be used on no_std w\o alloc at least)

Manishearth commented 4 years ago

Sure, PRs welcome. Ideally something that switches between arrayvec and a non panicky variant

tarcieri commented 4 years ago

...arrayvec and a non panicky variant

Oh, now I see ArrayVec doesn't have any fallible APIs and always panics on overflow. That's not great.

Elsewhere I use heapless::Vec which does provide fallible APIs, and a trait like this to abstract over heapless::Vec and heap-based data structures (really wish something like this were in core):

https://docs.rs/veriform/0.1.0/veriform/derive_helpers/trait.TryExtend.html