Learn from clippy.
This commit is contained in:
@@ -40,10 +40,12 @@ impl Into<char> for FerryLocation {
|
||||
}
|
||||
}
|
||||
|
||||
type ViewerResult = Result<Vec<FerryLocation>, MapOperationError>;
|
||||
|
||||
struct EvolvingMap {
|
||||
next_map: Option<Map<FerryLocation>>,
|
||||
occupation_tolerance: usize,
|
||||
view: fn(&Map<FerryLocation>, usize, usize) -> Result<Vec<FerryLocation>, MapOperationError>,
|
||||
view: fn(&Map<FerryLocation>, usize, usize) -> ViewerResult,
|
||||
}
|
||||
|
||||
impl From<Map<FerryLocation>> for EvolvingMap {
|
||||
|
||||
@@ -30,7 +30,7 @@ impl FromStr for Instruction {
|
||||
let instruction = items
|
||||
.next()
|
||||
.ok_or(InstructionParseError::EmptyInstruction)?;
|
||||
let operand = items.next().ok_or(InstructionParseError::MissingOperand(
|
||||
let operand = items.next().ok_or_else(|| InstructionParseError::MissingOperand(
|
||||
instruction.to_string(),
|
||||
))?;
|
||||
let operand_value = isize::from_str(operand)?;
|
||||
@@ -165,7 +165,7 @@ impl Iterator for VariantGenerator {
|
||||
}
|
||||
|
||||
fn main() -> Result<(), TopLevelError> {
|
||||
let filename = env::args().skip(1).next().expect("No file argument given.");
|
||||
let filename = env::args().nth(1).expect("No file argument given.");
|
||||
let contents = fs::read_to_string(filename)?;
|
||||
let machine = Machine::from_str(&contents)?;
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ fn third_example() {
|
||||
}
|
||||
|
||||
fn main() -> Result<(), TopLevelError> {
|
||||
let filename = env::args().skip(1).next().expect("No file argument given.");
|
||||
let filename = env::args().nth(1).expect("No file argument given.");
|
||||
let contents = fs::read_to_string(filename)?;
|
||||
let mut xmas_checker = XmasChecker::new(25);
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ impl<X: Clone> Map<X> {
|
||||
|
||||
pub fn at_unwrapped(&self, x: usize, y: usize) -> Option<X> {
|
||||
let row = self.data.get(y)?;
|
||||
row.get(x).map(|x| x.clone())
|
||||
row.get(x).cloned()
|
||||
}
|
||||
|
||||
fn view(&self, f: fn(&X) -> bool, x: usize, y: usize, rise: isize, run: isize) -> Option<X> {
|
||||
@@ -125,7 +125,7 @@ impl<X: Clone> Map<X> {
|
||||
Ok(results)
|
||||
}
|
||||
|
||||
pub fn locations<'a>(&'a self) -> MapLocations<'a, X> {
|
||||
pub fn locations(&self) -> MapLocations<X> {
|
||||
MapLocations {
|
||||
underlying: self,
|
||||
x: 0,
|
||||
@@ -176,7 +176,7 @@ impl<X: Clone + Into<char>> Map<X> {
|
||||
for x in 0..self.width {
|
||||
print!("{}", self.at(x, y).unwrap().into());
|
||||
}
|
||||
println!("");
|
||||
println!();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user