Skip to content

Commit

Permalink
fix: clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
Roger-luo committed Feb 10, 2023
1 parent 1d64691 commit 007c530
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/bin/ion/commands/new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ pub fn exec(config: &mut Config, matches: &ArgMatches) -> CliResult {
};
mk_package_dir(&path, force)?;

let mut ctx = Context::new(prompt, Julia::new(&config), Project::new(package, path));
let mut ctx = Context::new(prompt, Julia::new(config), Project::new(package, path));
let name = matches.get_one::<String>("template").unwrap().to_owned();
let template = Template::from_name(config, &name)?;
if let Err(e) = template.render(config, &mut ctx) {
Expand Down
2 changes: 1 addition & 1 deletion src/ion/blueprints/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ impl Context {
}
std::fs::create_dir_all(&path).unwrap();

let version = julia_version(&config)?;
let version = julia_version(config)?;
let compat = format!("{}.{}", version.major, version.minor);
let julia = Julia {
version: version.to_string(),
Expand Down
2 changes: 1 addition & 1 deletion src/ion/blueprints/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub struct Julia {

impl Julia {
pub fn new(config: &Config) -> Self {
let version = match julia_version(&config) {
let version = match julia_version(config) {
Ok(version) => version,
Err(_) => node_semver::Version::parse("1.6.0").unwrap(),
};
Expand Down
2 changes: 1 addition & 1 deletion src/ion/utils/julia.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ mod test {
pub fn assert_julia_version(config: &Config, version_spec: impl AsRef<str>) -> Result<()> {
let range = node_semver::Range::parse(version_spec.as_ref()).expect("Invalid version spec");
let version = julia_version(config)?;
range.satisfies(&version).then(|| ()).ok_or_else(|| {
range.satisfies(&version).then_some(()).ok_or_else(|| {
format_err!(
"Invalid Julia version: Julia version {version} does not satisfy version range {range}",
)
Expand Down
10 changes: 9 additions & 1 deletion tests/bin/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ pub struct Ion {
cmd: Command,
}



impl Ion {
pub fn new() -> Self {
let program = cargo_bin("ion");
Expand Down Expand Up @@ -87,12 +89,18 @@ impl Ion {
}
}

impl Default for Ion {
fn default() -> Self {
Self::new()
}
}

impl<'c> OutputAssertExt for &'c mut Ion {
fn assert(self) -> Assert {
let output = match self.output() {
Ok(output) => output,
Err(err) => {
panic!("Failed to spawn {:?}: {}", self, err);
panic!("Failed to spawn {self:?}: {err}");
}
};
Assert::new(output).append_context("command", format!("{:?}", self.cmd))
Expand Down

0 comments on commit 007c530

Please sign in to comment.