Confused on how to create and destroy repr_c::Vec
#112
Replies: 1 comment 5 replies
-
So, Anything beyond that, such as exposing an API to "work with a value of that type", has to be manually exported. In other words, it's:
but for each and every desired API: use ::safer_ffi::prelude::*;
#[derive_ReprC]
…
struct Item …
#[ffi_export]
fn vec_item_new ()
-> repr_c::Vec<Item>
{
c_vec![]
}
#[ffi_export]
fn vec_item_push (vec: &mut repr_c::Vec<Item>, item: Item)
{
vec.with_rust_mut(|v| v.push(item));
}
#[ffi_export]
fn vec_item_free (vec: repr_c::Vec<Item>)
{
drop(vec)
} If this were to become too annoying / cumbersome in some cases, feel free to detail such situations, so that I can think of ways to help automate this (for instance, |
Beta Was this translation helpful? Give feedback.
-
Question from @TheButlah, at #109:
Beta Was this translation helpful? Give feedback.
All reactions