Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions varlink_generator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ pub struct GeneratorOptions {
pub float_type: Option<&'static str>,
pub string_type: Option<&'static str>,
pub preamble: Option<TokenStream>,
pub fmt_style_edition: Option<&'static str>,
}

impl<'short, 'long: 'short> ToRustString<'short, 'long> for VType<'long> {
Expand Down Expand Up @@ -1059,6 +1060,7 @@ pub fn cargo_build_tosource<T: AsRef<Path> + ?Sized>(input_path: &T, rustfmt: bo
/// true,
/// &varlink_generator::GeneratorOptions {
/// int_type: Some("i128"),
/// fmt_style_edition: Some("2024"),
/// ..Default::default()
/// },
/// );
Expand Down Expand Up @@ -1110,10 +1112,13 @@ pub fn cargo_build_tosource_options<T: AsRef<Path> + ?Sized>(
}

if rustfmt {
if let Err(e) = Command::new("rustfmt")
.arg(rust_path.to_str().unwrap())
.output()
{
let mut cmd = Command::new("rustfmt");

if let Some(ref v) = options.fmt_style_edition {
cmd.args(["--style-edition", v]);
}

if let Err(e) = cmd.arg(rust_path.to_str().unwrap()).output() {
eprintln!(
"Could not run rustfmt on file `{}` {}",
rust_path.display(),
Expand Down