From a73712df8840c63210ce8aceed9d0738931e5317 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Fri, 21 Jan 2022 09:07:20 +0200 Subject: refactor: format code with rustfmt Sponsored-by: author --- src/bin/roadmap2dot.rs | 2 +- src/err.rs | 10 ++-------- src/map.rs | 10 ++++------ src/parser.rs | 2 +- 4 files changed, 8 insertions(+), 16 deletions(-) diff --git a/src/bin/roadmap2dot.rs b/src/bin/roadmap2dot.rs index b180da8..a9b7302 100644 --- a/src/bin/roadmap2dot.rs +++ b/src/bin/roadmap2dot.rs @@ -11,12 +11,12 @@ //! test the library crate. It is expected that serious use of the //! crate will be as a library. +use anyhow::Result; use roadmap::from_yaml; use std::fs::File; use std::io::Read; use std::path::PathBuf; use structopt::StructOpt; -use anyhow::Result; const LABEL_WIDTH: usize = 30; diff --git a/src/err.rs b/src/err.rs index b928b09..c5210f1 100644 --- a/src/err.rs +++ b/src/err.rs @@ -7,16 +7,10 @@ pub enum RoadmapError { NoGoals, #[error("too many goals, must have exactly one: found {count:}: {}", .names.join(", "))] - ManyGoals { - count: usize, - names: Vec, - }, + ManyGoals { count: usize, names: Vec }, #[error("step {name:} depends on missing {missing:}")] - MissingDep { - name: String, - missing: String, - }, + MissingDep { name: String, missing: String }, #[error("step is not a mapping")] StepNotMapping, diff --git a/src/map.rs b/src/map.rs index 874e537..e6a24a9 100644 --- a/src/map.rs +++ b/src/map.rs @@ -135,10 +135,7 @@ impl Roadmap { 1 => (), _ => { let names: Vec = goals.iter().map(|s| s.name().into()).collect(); - return Err(RoadmapError::ManyGoals { - count: n, - names, - }); + return Err(RoadmapError::ManyGoals { count: n, names }); } } @@ -146,11 +143,12 @@ impl Roadmap { for step in self.iter() { for depname in step.dependencies() { match self.get_step(depname) { - None => + None => { return Err(RoadmapError::MissingDep { name: step.name().into(), missing: depname.into(), - }), + }) + } Some(_) => (), } } diff --git a/src/parser.rs b/src/parser.rs index d83f618..6cc3d25 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -46,7 +46,7 @@ fn parse_depends(map: &Value) -> RoadmapResult> { let key_name = "depends"; let key = Value::String(key_name.to_string()); let mut depends: Vec<&str> = vec![]; - + match map.get(&key) { None => (), Some(Value::Sequence(deps)) => { -- cgit v1.2.1