Skip to content

Commit db7949f

Browse files
committed
derive Clone on Builder and all its fields
1 parent 1d25049 commit db7949f

File tree

7 files changed

+17
-6
lines changed

7 files changed

+17
-6
lines changed

Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ cexpr = "0.6"
5151
# This kinda sucks: https://github.com/rust-lang/cargo/issues/1982
5252
clap = { version = "2", optional = true }
5353
clang-sys = { version = "1", features = ["clang_6_0"] }
54+
dyn-clone = "1"
5455
lazycell = "1"
5556
lazy_static = "1"
5657
peeking_take_while = "0.1.2"

src/callbacks.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ impl Default for MacroParsingBehavior {
2525

2626
/// A trait to allow configuring different kinds of types in different
2727
/// situations.
28-
pub trait ParseCallbacks: fmt::Debug + UnwindSafe {
28+
pub trait ParseCallbacks: fmt::Debug + UnwindSafe + dyn_clone::DynClone {
2929
/// This function will be run on every macro that is identified.
3030
fn will_parse_macro(&self, _name: &str) -> MacroParsingBehavior {
3131
MacroParsingBehavior::Default
@@ -104,3 +104,5 @@ pub trait ParseCallbacks: fmt::Debug + UnwindSafe {
104104
vec![]
105105
}
106106
}
107+
108+
dyn_clone::clone_trait_object!(ParseCallbacks);

src/clang.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1687,6 +1687,7 @@ impl Drop for Diagnostic {
16871687
}
16881688

16891689
/// A file which has not been saved to disk.
1690+
#[derive(Clone)]
16901691
pub struct UnsavedFile {
16911692
x: CXUnsavedFile,
16921693
/// The name of the unsaved file. Kept here to avoid leaving dangling pointers in

src/deps.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/// Generating build depfiles from parsed bindings.
22
use std::{collections::BTreeSet, path::PathBuf};
33

4-
#[derive(Debug)]
4+
#[derive(Clone, Debug)]
55
pub(crate) struct DepfileSpec {
66
pub output_module: String,
77
pub depfile_path: PathBuf,

src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ impl Default for CodegenConfig {
219219
/// End-users of the crate may need to set the `BINDGEN_EXTRA_CLANG_ARGS` environment variable to
220220
/// add additional arguments. For example, to build against a different sysroot a user could set
221221
/// `BINDGEN_EXTRA_CLANG_ARGS` to `--sysroot=/path/to/sysroot`.
222-
#[derive(Debug, Default)]
222+
#[derive(Clone, Debug, Default)]
223223
pub struct Builder {
224224
options: BindgenOptions,
225225
input_headers: Vec<String>,
@@ -1663,7 +1663,7 @@ impl Builder {
16631663
}
16641664

16651665
/// Configuration options for generated bindings.
1666-
#[derive(Debug)]
1666+
#[derive(Clone, Debug)]
16671667
struct BindgenOptions {
16681668
/// The set of types that have been blocklisted and should not appear
16691669
/// anywhere in the generated code.
@@ -2656,7 +2656,7 @@ fn get_target_dependent_env_var(var: &str) -> Option<String> {
26562656
/// .parse_callbacks(Box::new(bindgen::CargoCallbacks))
26572657
/// .generate();
26582658
/// ```
2659-
#[derive(Debug)]
2659+
#[derive(Clone, Debug)]
26602660
pub struct CargoCallbacks;
26612661

26622662
impl callbacks::ParseCallbacks for CargoCallbacks {

src/regex_set.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use regex::RegexSet as RxSet;
44
use std::cell::Cell;
55

66
/// A dynamic set of regular expressions.
7-
#[derive(Debug, Default)]
7+
#[derive(Clone, Debug, Default)]
88
pub struct RegexSet {
99
items: Vec<String>,
1010
/// Whether any of the items in the set was ever matched. The length of this

0 commit comments

Comments
 (0)