• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 use crate::rust_slice::RustSlice;
2 use core::mem::MaybeUninit;
3 use core::ptr::{self, NonNull};
4 
5 #[export_name = "cxxbridge1$slice$new"]
slice_new(this: &mut MaybeUninit<RustSlice>, ptr: NonNull<()>, len: usize)6 unsafe extern "C" fn slice_new(this: &mut MaybeUninit<RustSlice>, ptr: NonNull<()>, len: usize) {
7     let this = this.as_mut_ptr();
8     let rust_slice = RustSlice::from_raw_parts(ptr, len);
9     unsafe { ptr::write(this, rust_slice) }
10 }
11 
12 #[export_name = "cxxbridge1$slice$ptr"]
slice_ptr(this: &RustSlice) -> NonNull<()>13 unsafe extern "C" fn slice_ptr(this: &RustSlice) -> NonNull<()> {
14     this.as_non_null_ptr()
15 }
16 
17 #[export_name = "cxxbridge1$slice$len"]
slice_len(this: &RustSlice) -> usize18 unsafe extern "C" fn slice_len(this: &RustSlice) -> usize {
19     this.len()
20 }
21