Skip to content

Commit 72978e8

Browse files
committed
Add bindgen::Builder::derive_copy
1 parent d23db77 commit 72978e8

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/lib.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,12 @@ impl Builder {
735735
self
736736
}
737737

738+
/// Set whether `Copy` should be derived by default.
739+
pub fn derive_copy(mut self, doit: bool) -> Self {
740+
self.options.derive_copy = doit;
741+
self
742+
}
743+
738744
/// Set whether `Debug` should be derived by default.
739745
pub fn derive_debug(mut self, doit: bool) -> Self {
740746
self.options.derive_debug = doit;
@@ -1104,6 +1110,10 @@ pub struct BindgenOptions {
11041110
/// True if we should generate layout tests for generated structures.
11051111
pub layout_tests: bool,
11061112

1113+
/// True if we should derive Copy trait implementations for C/C++ structures
1114+
/// and types.
1115+
pub derive_copy: bool,
1116+
11071117
/// True if we should derive Debug trait implementations for C/C++ structures
11081118
/// and types.
11091119
pub derive_debug: bool,
@@ -1269,6 +1279,7 @@ impl Default for BindgenOptions {
12691279
emit_ir: false,
12701280
emit_ir_graphviz: None,
12711281
layout_tests: true,
1282+
derive_copy: true,
12721283
derive_debug: true,
12731284
impl_debug: false,
12741285
derive_default: false,

src/options.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ where
6161
Arg::with_name("no-layout-tests")
6262
.long("no-layout-tests")
6363
.help("Avoid generating layout tests for any type."),
64+
Arg::with_name("no-derive-copy")
65+
.long("no-derive-copy")
66+
.help("Avoid deriving Copy on any type."),
6467
Arg::with_name("no-derive-debug")
6568
.long("no-derive-debug")
6669
.help("Avoid deriving Debug on any type."),

0 commit comments

Comments
 (0)