diff --git a/bindgen-tests/tests/parse_callbacks/add_derives_callback/mod.rs b/bindgen-tests/tests/parse_callbacks/add_derives_callback/mod.rs index 570cef7ce1..4b6f210dce 100644 --- a/bindgen-tests/tests/parse_callbacks/add_derives_callback/mod.rs +++ b/bindgen-tests/tests/parse_callbacks/add_derives_callback/mod.rs @@ -20,7 +20,7 @@ mod tests { } fn write_bindings_to_string(bindings: &Bindings) -> String { - let mut output = Vec::::new(); + let mut output = vec![]; bindings.write(&mut output).unwrap_or_else(|e| { panic!("Failed to write generated bindings: {e}") }); diff --git a/bindgen/lib.rs b/bindgen/lib.rs index e7ea44e19a..0305b5cd7b 100644 --- a/bindgen/lib.rs +++ b/bindgen/lib.rs @@ -927,17 +927,17 @@ impl Bindings { /// Write these bindings as source text to a file. pub fn write_to_file>(&self, path: P) -> io::Result<()> { - let mut file = OpenOptions::new() + let file = OpenOptions::new() .write(true) .truncate(true) .create(true) .open(path.as_ref())?; - self.write(&mut file)?; + self.write(file)?; Ok(()) } /// Write these bindings as source text to the given `Write`able. - pub fn write(&self, writer: &mut dyn Write) -> io::Result<()> { + pub fn write(&self, mut writer: impl Write) -> io::Result<()> { const NL: &str = if cfg!(windows) { "\r\n" } else { "\n" }; if !self.options.disable_header_comment {