From 16fc483ea1cff63dccbd7db70a7dec46051d7f4b Mon Sep 17 00:00:00 2001 From: Dima Kudosh Date: Tue, 1 Mar 2016 15:00:07 +0300 Subject: [PATCH] Remove warnings --- src/differ.rs | 9 ++++----- src/lib.rs | 2 +- src/sequencematcher.rs | 4 ++-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/differ.rs b/src/differ.rs index 8721d76..66caa0c 100644 --- a/src/differ.rs +++ b/src/differ.rs @@ -53,8 +53,8 @@ impl Differ{ if !(first_start < first_end && second_start < second_end){ return Vec::new(); } - let mut first = Vec::new(); - let mut second = Vec::new(); + let mut first; + let second; if second_end - second_start < first_end - first_start{ first = self.dump("+", second_sequence, second_start, second_end); second = self.dump("-", first_sequence, first_start, first_end); @@ -73,7 +73,7 @@ impl Differ{ let mut res = Vec::new(); let (mut best_ratio, cutoff) = (0.74, 0.75); let (mut best_i, mut best_j) = (0, 0); - let (mut second_sequence_str, mut first_sequence_str) = ("", ""); + let (mut second_sequence_str, mut first_sequence_str); let mut eqi: Option = None; let mut eqj: Option = None; for j in second_start..second_end{ @@ -103,7 +103,6 @@ impl Differ{ } best_i = eqi.unwrap(); best_j = eqj.unwrap(); - best_ratio = 1.0; } else { eqi = None; } @@ -187,7 +186,7 @@ impl Differ{ panic!("Second parameter must be 1 or 2"); } let mut res = Vec::new(); - let mut tag = String::new(); + let tag; if which == 1 { tag = "- ".to_string(); } else { diff --git a/src/lib.rs b/src/lib.rs index e35731e..f479871 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -107,7 +107,7 @@ pub fn context_diff(first_sequence: &T, second_sequence: &T, from_f } } let file2_range = format_range_context(first.second_start, last.second_end); - res.push(format!("--- {} ----{}", file1_range, lineterm)); + res.push(format!("--- {} ----{}", file2_range, lineterm)); any = false; for opcode in group { if opcode.tag == "replace" || opcode.tag == "insert" { diff --git a/src/sequencematcher.rs b/src/sequencematcher.rs index e47a5d6..6bccd52 100644 --- a/src/sequencematcher.rs +++ b/src/sequencematcher.rs @@ -1,5 +1,5 @@ use std::collections::HashMap; -use std::cmp::{Ordering, max, min}; +use std::cmp::{max, min}; use utils::calculate_ratio; use std::fmt::Debug; @@ -67,7 +67,7 @@ impl<'a> Sequence for Vec<&'a str> { } fn at_index(&self, index: usize) -> Option<&str> { - if index < self.len() && index >= 0 { + if index < self.len() { return Some(self[index]) } None