Skip to content

Commit e96906f

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

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/lib.rs

+15
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,10 @@ impl Builder {
253253
output_vector.push("--no-layout-tests".into());
254254
}
255255

256+
if !self.options.derive_copy {
257+
output_vector.push("--no-derive-copy".into());
258+
}
259+
256260
if !self.options.derive_debug {
257261
output_vector.push("--no-derive-debug".into());
258262
}
@@ -735,6 +739,12 @@ impl Builder {
735739
self
736740
}
737741

742+
/// Set whether `Copy` should be derived by default.
743+
pub fn derive_copy(mut self, doit: bool) -> Self {
744+
self.options.derive_copy = doit;
745+
self
746+
}
747+
738748
/// Set whether `Debug` should be derived by default.
739749
pub fn derive_debug(mut self, doit: bool) -> Self {
740750
self.options.derive_debug = doit;
@@ -1104,6 +1114,10 @@ pub struct BindgenOptions {
11041114
/// True if we should generate layout tests for generated structures.
11051115
pub layout_tests: bool,
11061116

1117+
/// True if we should derive Copy trait implementations for C/C++ structures
1118+
/// and types.
1119+
pub derive_copy: bool,
1120+
11071121
/// True if we should derive Debug trait implementations for C/C++ structures
11081122
/// and types.
11091123
pub derive_debug: bool,
@@ -1269,6 +1283,7 @@ impl Default for BindgenOptions {
12691283
emit_ir: false,
12701284
emit_ir_graphviz: None,
12711285
layout_tests: true,
1286+
derive_copy: true,
12721287
derive_debug: true,
12731288
impl_debug: false,
12741289
derive_default: false,

src/options.rs

+7
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."),
@@ -311,6 +314,10 @@ where
311314
builder = builder.layout_tests(false);
312315
}
313316

317+
if matches.is_present("no-derive-copy") {
318+
builder = builder.derive_copy(false);
319+
}
320+
314321
if matches.is_present("no-derive-debug") {
315322
builder = builder.derive_debug(false);
316323
}

0 commit comments

Comments
 (0)