diff options
-rw-r--r-- | src/ir/comp.rs | 14 | ||||
-rw-r--r-- | src/lib.rs | 12 | ||||
-rw-r--r-- | src/options.rs | 6 |
3 files changed, 13 insertions, 19 deletions
diff --git a/src/ir/comp.rs b/src/ir/comp.rs index c44e20f5..22c124fa 100644 --- a/src/ir/comp.rs +++ b/src/ir/comp.rs @@ -825,15 +825,11 @@ impl CompFields { } anon_field_counter += 1; - if let Some(ref prefix) = ctx.options().anon_fields_prefix { - *name = - Some(format!("{}{}", prefix, anon_field_counter)); - } else { - *name = Some(format!( - "__bindgen_anon_{}", - anon_field_counter - )); - } + *name = Some(format!( + "{}{}", + ctx.options().anon_fields_prefix, + anon_field_counter + )); } Field::Bitfields(ref mut bu) => { for bitfield in &mut bu.bitfields { @@ -385,7 +385,7 @@ impl Builder { output_vector.push(prefix.clone()); } - if let Some(ref prefix) = self.options.anon_fields_prefix { + if let prefix = &self.options.anon_fields_prefix { output_vector.push("--anon-fields-prefix".into()); output_vector.push(prefix.clone()); } @@ -1217,9 +1217,9 @@ impl Builder { self } - /// Use the given prefix for the anon fields instead of `__bindgen_anon_`. + /// Use the given prefix for the anon fields. pub fn anon_fields_prefix<T: Into<String>>(mut self, prefix: T) -> Builder { - self.options.anon_fields_prefix = Some(prefix.into()); + self.options.anon_fields_prefix = prefix.into(); self } @@ -1601,8 +1601,8 @@ struct BindgenOptions { /// An optional prefix for the "raw" types, like `c_int`, `c_void`... ctypes_prefix: Option<String>, - /// An optional prefix for the anon fields instead of `__bindgen_anon_`. - anon_fields_prefix: Option<String>, + /// The prefix for the anon fields. + anon_fields_prefix: String, /// Whether to time the bindgen phases. time_phases: bool, @@ -1823,7 +1823,7 @@ impl Default for BindgenOptions { disable_header_comment: false, use_core: false, ctypes_prefix: None, - anon_fields_prefix: None, + anon_fields_prefix: "__bindgen_anon_".into(), namespaced_constants: true, msvc_mangling: false, convert_floats: true, diff --git a/src/options.rs b/src/options.rs index 8dc80e1e..4844b91a 100644 --- a/src/options.rs +++ b/src/options.rs @@ -236,11 +236,9 @@ where .takes_value(true), Arg::with_name("anon-fields-prefix") .long("anon-fields-prefix") - .help( - "Use the given prefix for the anon fields instead of \ - __bindgen_anon_.", - ) + .help("Use the given prefix for the anon fields.") .value_name("prefix") + .default_value("__bindgen_anon_") .takes_value(true), Arg::with_name("time-phases") .long("time-phases") |