seestr

Crates.ioseestr
lib.rsseestr
version0.1.5
sourcesrc
created_at2024-11-28 22:24:13.808329
updated_at2024-11-29 07:08:48.809062
descriptionpointer-wide nul-terminated strings with ownership semantics
homepagehttps://crates.io/crates/seestr
repositoryhttps://github.com/aatifsyed/seestr
max_upload_size
id1465025
size20,364
Aatif Syed (aatifsyed)

documentation

https://docs.rs/seestr

README

Pointer-wide nul-terminated strings for use in FFI.

The following C API:

char *create(void); // may return nul
void destroy(char *);
char *get_name(struct has_name *); // may return nul
char *version(void); // never null

Can be transcribed as follows:

extern "C" {
    fn create() -> Option<Buf>;
    fn destroy(_: Buf);
    fn get_name(_: &HasName) -> Option<&NulTerminated>;
    fn version() -> &'static NulTerminated;
}

As opposed to:

extern "C" {
    fn create() -> *mut c_char;
    fn destroy(_: *mut c_char);
    fn get_name(_: *mut HasName) -> *mut c_char;
    fn version() -> *mut c_char;
}
Commit count: 29

cargo fmt