diff options
-rw-r--r-- | book/src/using-unions.md | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/book/src/using-unions.md b/book/src/using-unions.md index 3f74b2ff..66ba6d13 100644 --- a/book/src/using-unions.md +++ b/book/src/using-unions.md @@ -25,11 +25,23 @@ typedef union { } greek_t; ``` +## Relevant Bindgen Options + +### Library + +* [`bindgen::Builder::no_unstable_rust()`](https://docs.rs/bindgen/0.25.3/bindgen/struct.Builder.html#method.no_unstable_rust) +* [`bindgen::Builder::derive_default()`](https://docs.rs/bindgen/0.25.3/bindgen/struct.Builder.html#method.derive_default) + +### Command Line + +* `--no-unstable-rust` +* `--with-derive-default` + ## Using the unstable `union` version With `struct`s generated by bindgen from C, it is possible to initialize fields in a "normal" rust way: -```rust +```rust,ignore mod bindings; fn main() { @@ -42,7 +54,7 @@ fn main() { When using the unstable `union` type, there are two choices for initialization: Zeroed, and with a specific variant. -```rust +```rust,ignore #![feature(untagged_unions)] mod bindings_unstable; @@ -75,7 +87,7 @@ For versions of Rust that do not support the new `union` type, bindgen will gene Interacting with these unions is slightly different than the new `union` types. Whenever a variant of the union is accessed, it must be done through a reference. -```rust +```rust,ignore mod bindings; fn stable() { |