mirror of
https://gitee.com/openharmony/third_party_rust_bindgen
synced 2025-03-04 12:47:22 +00:00

Emit `PhantomData<UnsafeCell<T>>` members for all generic parameters This makes generated generic structs lifetime invariant, since we cannot know the C++ type's true variance. Fixes #506 Rebased + squashed version of #635; cc @Kowasaki To resolve the conflicts and rebase and squash, I did essentially these commands: ``` $ git fetch servo $ git checkout -b Kowasaki-master servo/master $ git merge --squash --edit Kowasaki/master $ cargo test $ cd tests/expectations $ cargo test $ cd - $ git commit --author="Kowasaki" $ git push fitzgen Kowasaki-master ``` Hopefully that is useful for you in the future :) Thanks for fixing this issue!
bindgen
bindgen
automatically generates Rust FFI bindings to C and C++ libraries.
For example, given the C header cool.h
:
typedef struct CoolStruct {
int x;
int y;
} CoolStruct;
void cool_function(int i, char c, CoolStruct* cs);
bindgen
produces Rust FFI code allowing you to call into the cool
library's
functions and use its types:
/* automatically generated by rust-bindgen */
#[repr(C)]
pub struct CoolStruct {
pub x: ::std::os::raw::c_int,
pub y: ::std::os::raw::c_int,
}
extern "C" {
pub fn cool_function(i: ::std::os::raw::c_int,
c: ::std::os::raw::c_char,
cs: *mut CoolStruct);
}
Users Guide
📚 Read the bindgen
users guide here! 📚
API Reference
API reference documentation is on docs.rs
Contributing
Description
Languages
Rust
97.6%
Python
1.6%
Shell
0.6%
Batchfile
0.1%
C
0.1%