1 unstable release
0.1.0 | Nov 30, 2024 |
---|
#2381 in Rust patterns
169 downloads per month
26KB
561 lines
FFI-safe types for writing and transcribing C APIs.
&CStr
and CString
are not FFI safe.
#[deny(improper_ctypes)]
extern "C" {
fn concat(_: &CStr, _: &CStr) -> CString;
}
&SeaStr
and SeaString
are FFI-safe equivalents.
extern "C" {
fn concat(_: &SeaStr, _: &SeaStr) -> SeaString;
}
They use the non-null niche which is filled by Option::None
.
/** may return null */
char *foo(void);
extern "C" fn foo() -> Option<SeaString> { .. }
assert_eq!(size_of::<Option<SeaString>>(), size_of::<*mut c_char>());
SeaBox
is an additional owned pointer type, with a pluggable Allocator
.
lib.rs
:
FFI-safe types for writing and transcribing C APIs.
&CStr
and CString
are not FFI safe.
#[deny(improper_ctypes)]
extern "C" {
fn concat(_: &CStr, _: &CStr) -> CString;
}
&SeaStr
and SeaString
are FFI-safe equivalents.
extern "C" {
fn concat(_: &SeaStr, _: &SeaStr) -> SeaString;
}
They use the non-null niche which is filled by Option::None
.
/** may return null */
char *foo(void);
extern "C" fn foo() -> Option<SeaString> { .. }
assert_eq!(size_of::<Option<SeaString>>(), size_of::<*mut c_char>());
SeaBox
is an additional owned pointer type, with a pluggable Allocator
.
Dependencies
~43KB