mirror of
https://github.com/topjohnwu/cxx.git
synced 2025-02-14 12:49:23 +00:00
Simplify to_c_error by using NonNull inline
This commit is contained in:
parent
6c12520836
commit
837eefee5e
@ -41,14 +41,11 @@ unsafe fn to_c_error(msg: String) -> Result {
|
||||
|
||||
extern "C" {
|
||||
#[link_name = "cxxbridge1$error"]
|
||||
fn error(ptr: *const u8, len: usize) -> *const u8;
|
||||
fn error(ptr: *const u8, len: usize) -> NonNull<u8>;
|
||||
}
|
||||
|
||||
let copy = error(ptr, len);
|
||||
let err = PtrLen {
|
||||
ptr: NonNull::new_unchecked(copy as *mut u8),
|
||||
len,
|
||||
};
|
||||
let err = PtrLen { ptr: copy, len };
|
||||
Result { err }
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user