string-interner icon indicating copy to clipboard operation
string-interner copied to clipboard

RFE: Intern C-FFI compatible strings

Open dralley opened this issue 4 years ago • 1 comments

I have a project for which I will eventually (probably) want to provide C bindings. It would be enormously convenient if there was a variant of (or feature flag for) the string interner backend which left an extra null-termination byte at the end of every interned string, such that the str_from_interner.as_ptr() could be used from C without first copying the whole string to a new CString.

Is this possible, or am I missing some details which might make this unsafe to do?

dralley avatar Dec 09 '21 22:12 dralley

That's a decent request and it may make sense to adjust the string_interner crate in order to support this use case. It is more a question about a proper API design for this issue. Is there a specific API that you'd like to see as a string_interner user?

Robbepop avatar Dec 09 '21 23:12 Robbepop