rust-objc
rust-objc copied to clipboard
API for passing already nul-terminated strings to avoid allocation
Currently, in the runtime and declare modules, the API takes &str for ease of use. However, this requires copying the string into a buffer and adding a nul terminator byte. It might be desirable for some cases to have a way to pass in strings which are already known to be nul-terminated so that this allocation can be avoided.
Exploring some options here and created the nul crate.
Currently conflicted on whether that's the best solution. I'm realizing that really, the only strings that need to be provided are names (of classes, ivars, methods, etc). We could make an even nicer macro for generating those because they're idents. Maybe something like name!(NSObject) instead of ntstr!("NSObject"). At that point, is a separate crate even worth it? Or should we just have an objc::Name struct for encapsulating this.