Skip to content

Commit

Permalink
rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
ia0 committed Dec 9, 2024
1 parent efdae3e commit aa0c3ce
Show file tree
Hide file tree
Showing 108 changed files with 299 additions and 394 deletions.
2 changes: 1 addition & 1 deletion crates/api-desc/crates/update/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.

use std::fs::File;
use std::io::{stdout, Write};
use std::io::{Write, stdout};

use anyhow::Result;
use clap::{Parser, ValueEnum};
Expand Down
6 changes: 1 addition & 5 deletions crates/api-desc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -696,11 +696,7 @@ impl std::fmt::Display for Path<'_> {
Path::Empty => return Ok(()),
Path::Mod { name, prev } => (name, prev),
};
if f.alternate() {
write!(f, "{prev:#} ")
} else {
write!(f, "{prev}{name}_")
}
if f.alternate() { write!(f, "{prev:#} ") } else { write!(f, "{prev}{name}_") }
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/api/src/wasm/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use core::ffi::{c_char, CStr};
use core::ffi::{CStr, c_char};

use wasefire_logger as log;

Expand Down
2 changes: 1 addition & 1 deletion crates/board/src/usb/serial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

//! USB serial interface.
use usb_device::class_prelude::UsbBus;
use usb_device::UsbError;
use usb_device::class_prelude::UsbBus;
use usbd_serial::SerialPort;
use wasefire_logger as log;

Expand Down
10 changes: 5 additions & 5 deletions crates/cli-tools/src/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ use std::fmt::Display;
use std::path::{Path, PathBuf};
use std::time::Duration;

use anyhow::{bail, ensure, Result};
use anyhow::{Result, bail, ensure};
use clap::{ValueEnum, ValueHint};
use rusb::GlobalContext;
use tokio::process::Command;
use wasefire_protocol::{self as service, applet, Connection, ConnectionExt};
use wasefire_protocol::{self as service, Connection, ConnectionExt, applet};
use wasefire_wire::{self as wire, Yoke};

use crate::cargo::metadata;
Expand Down Expand Up @@ -367,9 +367,9 @@ impl Transfer {
) -> Result<()>
where
S: for<'a> service::Service<
Request<'a> = service::transfer::Request<'a>,
Response<'a> = (),
>,
Request<'a> = service::transfer::Request<'a>,
Response<'a> = (),
>,
{
use wasefire_protocol::transfer::Request;
let Transfer { dry_run, chunk_size } = self;
Expand Down
2 changes: 1 addition & 1 deletion crates/cli-tools/src/action/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use std::path::PathBuf;
use std::str::FromStr;
use std::time::Duration;

use anyhow::{bail, ensure, Result};
use anyhow::{Result, bail, ensure};
use data_encoding::HEXLOWER_PERMISSIVE as HEX;
use rusb::{Device, GlobalContext};
use wasefire_protocol::{self as service, Connection, ConnectionExt};
Expand Down
2 changes: 1 addition & 1 deletion crates/cli-tools/src/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

use std::path::PathBuf;

use anyhow::{ensure, Result};
use anyhow::{Result, ensure};
use cargo_metadata::{Metadata, MetadataCommand};

pub async fn metadata(dir: impl Into<PathBuf>) -> Result<Metadata> {
Expand Down
233 changes: 94 additions & 139 deletions crates/cli-tools/src/changelog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use std::collections::BTreeMap;
use std::fmt::Display;
use std::io::BufRead;

use anyhow::{anyhow, bail, ensure, Context, Result};
use anyhow::{Context, Result, anyhow, bail, ensure};
use clap::ValueEnum;
use semver::Version;
use tokio::process::Command;
Expand Down Expand Up @@ -315,70 +315,46 @@ mod tests {
<!-- Increment to skip CHANGELOG.md test: 0 -->
";

assert_eq!(
Changelog::parse(changelog).unwrap(),
Changelog {
releases: vec![
Release {
version: Version::parse("0.3.0").unwrap(),
contents: BTreeMap::from([
(
Severity::Major,
vec![
"- major update 1".to_string(),
"- major update 2".to_string()
]
),
(
Severity::Minor,
vec![
"- minor update 1".to_string(),
"- minor update 2".to_string()
]
),
(
Severity::Patch,
vec![
"- patch update 1".to_string(),
"- patch update 2".to_string()
]
)
assert_eq!(Changelog::parse(changelog).unwrap(), Changelog {
releases: vec![
Release {
version: Version::parse("0.3.0").unwrap(),
contents: BTreeMap::from([
(Severity::Major, vec![
"- major update 1".to_string(),
"- major update 2".to_string()
]),
},
Release {
version: Version::parse("0.2.0").unwrap(),
contents: BTreeMap::from([
(
Severity::Major,
vec![
"- major update 1".to_string(),
"- major update 2".to_string()
]
),
(
Severity::Minor,
vec![
"- minor update 1".to_string(),
"- minor update 2".to_string()
]
),
(
Severity::Patch,
vec![
"- patch update 1".to_string(),
"- patch update 2".to_string()
]
)
(Severity::Minor, vec![
"- minor update 1".to_string(),
"- minor update 2".to_string()
]),
},
Release {
version: Version::parse("0.1.0").unwrap(),
contents: BTreeMap::new(),
}
],
skip_counter: 0,
}
);
(Severity::Patch, vec![
"- patch update 1".to_string(),
"- patch update 2".to_string()
])
]),
},
Release {
version: Version::parse("0.2.0").unwrap(),
contents: BTreeMap::from([
(Severity::Major, vec![
"- major update 1".to_string(),
"- major update 2".to_string()
]),
(Severity::Minor, vec![
"- minor update 1".to_string(),
"- minor update 2".to_string()
]),
(Severity::Patch, vec![
"- patch update 1".to_string(),
"- patch update 2".to_string()
])
]),
},
Release { version: Version::parse("0.1.0").unwrap(), contents: BTreeMap::new() }
],
skip_counter: 0,
});
}

#[test]
Expand Down Expand Up @@ -457,39 +433,33 @@ mod tests {
<!-- Increment to skip CHANGELOG.md test: 0 -->
";

assert_eq!(
Changelog::parse(changelog).unwrap(),
Changelog {
releases: vec![
Release {
version: Version::parse("0.2.0").unwrap(),
contents: BTreeMap::from([(
Severity::Major,
vec!["- major update 1".to_string(), "- major update 2".to_string()]
)]),
},
Release {
version: Version::parse("0.1.2").unwrap(),
contents: BTreeMap::from([(
Severity::Minor,
vec!["- minor update 1".to_string(), "- minor update 2".to_string()]
)]),
},
Release {
version: Version::parse("0.1.1").unwrap(),
contents: BTreeMap::from([(
Severity::Patch,
vec!["- patch update 1".to_string(), "- patch update 2".to_string()]
)]),
},
Release {
version: Version::parse("0.1.0").unwrap(),
contents: BTreeMap::new(),
}
],
skip_counter: 0,
}
);
assert_eq!(Changelog::parse(changelog).unwrap(), Changelog {
releases: vec![
Release {
version: Version::parse("0.2.0").unwrap(),
contents: BTreeMap::from([(Severity::Major, vec![
"- major update 1".to_string(),
"- major update 2".to_string()
])]),
},
Release {
version: Version::parse("0.1.2").unwrap(),
contents: BTreeMap::from([(Severity::Minor, vec![
"- minor update 1".to_string(),
"- minor update 2".to_string()
])]),
},
Release {
version: Version::parse("0.1.1").unwrap(),
contents: BTreeMap::from([(Severity::Patch, vec![
"- patch update 1".to_string(),
"- patch update 2".to_string()
])]),
},
Release { version: Version::parse("0.1.0").unwrap(), contents: BTreeMap::new() }
],
skip_counter: 0,
});
}

#[test]
Expand All @@ -510,29 +480,20 @@ mod tests {
<!-- Increment to skip CHANGELOG.md test: 0 -->
";

assert_eq!(
Changelog::parse(changelog).unwrap(),
Changelog {
releases: vec![
Release {
version: Version::parse("0.2.0").unwrap(),
contents: BTreeMap::from([(
Severity::Major,
vec![
"- short 1".to_string(),
"- my long description\n that spans many lines".to_string(),
"- short 2".to_string()
]
)]),
},
Release {
version: Version::parse("0.1.0").unwrap(),
contents: BTreeMap::new(),
}
],
skip_counter: 0,
}
);
assert_eq!(Changelog::parse(changelog).unwrap(), Changelog {
releases: vec![
Release {
version: Version::parse("0.2.0").unwrap(),
contents: BTreeMap::from([(Severity::Major, vec![
"- short 1".to_string(),
"- my long description\n that spans many lines".to_string(),
"- short 2".to_string()
])]),
},
Release { version: Version::parse("0.1.0").unwrap(), contents: BTreeMap::new() }
],
skip_counter: 0,
});
}

#[test]
Expand Down Expand Up @@ -565,16 +526,13 @@ mod tests {
<!-- Increment to skip CHANGELOG.md test: 0 -->
";

assert_eq!(
Changelog::parse(changelog).unwrap(),
Changelog {
releases: vec![Release {
version: Version::parse("0.1.0").unwrap(),
contents: BTreeMap::new(),
}],
skip_counter: 0,
}
);
assert_eq!(Changelog::parse(changelog).unwrap(), Changelog {
releases: vec![Release {
version: Version::parse("0.1.0").unwrap(),
contents: BTreeMap::new(),
}],
skip_counter: 0,
});
}

#[test]
Expand All @@ -586,16 +544,13 @@ mod tests {
<!-- Increment to skip CHANGELOG.md test: 5 -->
";

assert_eq!(
Changelog::parse(changelog).unwrap(),
Changelog {
releases: vec![Release {
version: Version::parse("0.1.0").unwrap(),
contents: BTreeMap::new(),
}],
skip_counter: 5,
}
);
assert_eq!(Changelog::parse(changelog).unwrap(), Changelog {
releases: vec![Release {
version: Version::parse("0.1.0").unwrap(),
contents: BTreeMap::new(),
}],
skip_counter: 5,
});
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion crates/cli-tools/src/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use std::os::unix::process::CommandExt;
use std::process::Output;

use anyhow::{ensure, Context, Result};
use anyhow::{Context, Result, ensure};
use tokio::process::{Child, Command};

/// Spawns a command.
Expand Down
2 changes: 1 addition & 1 deletion crates/cli-tools/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ use std::io::ErrorKind;
use std::path::{Component, Path, PathBuf};

use anyhow::{Context, Result};
use serde::de::DeserializeOwned;
use serde::Serialize;
use serde::de::DeserializeOwned;
use tokio::fs::{File, OpenOptions, ReadDir};
use tokio::io::{AsyncReadExt, AsyncWriteExt};

Expand Down
2 changes: 1 addition & 1 deletion crates/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use std::fs::File;
use std::io::Write;
use std::path::{Path, PathBuf};

use anyhow::{bail, ensure, Context, Result};
use anyhow::{Context, Result, bail, ensure};
use clap::{CommandFactory, Parser, ValueHint};
use clap_complete::Shell;
use tokio::process::Command;
Expand Down
Loading

0 comments on commit aa0c3ce

Please sign in to comment.