Make anon-fields-prefix non-optional

This commit is contained in:
Darren Kulp 2020-08-02 14:49:48 -07:00 committed by Emilio Cobos Álvarez
parent dfeff8992e
commit 4a75b21c13
3 changed files with 13 additions and 19 deletions

View File

@ -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 {

View File

@ -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,

View File

@ -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")