ParkMyCar / compact_str

A memory efficient string type that can store up to 24* bytes on the stack
MIT License
638 stars 46 forks source link

Support creating CompactString from &'static str in O(1) #264

Closed NobodyXu closed 1 year ago

NobodyXu commented 1 year ago

I encounter several scenariors where I want to create a CompactString from &'static str and it would be great if that can be done in O(1) by simply storing a reference to the 'static str

Kijewski commented 1 year ago

I guess this is a special case of #223? I won't find the time to work on this PR in the foreseeable future, though.

NobodyXu commented 1 year ago

I guess this is a special case of #223? I won't find the time to work on this PR in the foreseeable future, though.

Yeah, I would like to have something like:

impl CompactString {
    fn from_static(s: &'static str) -> Self;
}

I could try to implement this myself, though I am also a bit busy recently.