Debian Codegraph @

third_party/rust/diplomat/src/snapshots/diplomat__tests__method_taking_owned_str.snap

raw
1 ---
2 source: macro/src/lib.rs
3 expression: "rustfmt_code(&gen_bridge(parse_quote! {\n mod ffi\n {\n struct Foo {} impl Foo\n {\n pub fn something_with_str(s : Box < str >)\n { unimplemented! () }\n }\n }\n }).to_token_stream().to_string())"
4 ---
5 mod ffi {
6 #[repr(C)]
7 #[derive(Clone, Copy)]
8 struct Foo {}
9 impl Foo {
10 pub fn something_with_str(s: Box<str>) {
11 unimplemented!()
12 }
13 }
14 use diplomat_runtime::*;
15 #[no_mangle]
16 extern "C" fn Foo_something_with_str(s_diplomat_data: *mut u8, s_diplomat_len: usize) {
17 Foo::something_with_str(if s_diplomat_len == 0 {
18 Default::default()
19 } else {
20 unsafe {
21 core::str::from_boxed_utf8_unchecked(alloc::boxed::Box::from_raw(
22 core::ptr::slice_from_raw_parts_mut(s_diplomat_data, s_diplomat_len),
23 ))
24 }
25 })
26 }
27 #[no_mangle]
28 extern "C" fn Foo_destroy(this: Box<Foo>) {}
29 }
30