mrdimidium / nanoid

A tiny, secure, URL-friendly, unique string ID generator for Rust
https://docs.rs/nanoid
MIT License
545 stars 29 forks source link

Add "smartstring" feature #29

Closed merlinfuchs closed 2 years ago

merlinfuchs commented 2 years ago

This PR adds support for generating smartstring::SmartString instead of normal Strings. This can avoid a heap allocation when the ID is smaller than 23 ASCII characters. (which is the case by default) An initial capacity isn't supported by SmartString so I had to replace it with String::new when the feature is enabled.

More info: https://docs.rs/smartstring

mrdimidium commented 2 years ago

Thanks for your contribution! Will be available with the next patch