cut: fix build

This commit is contained in:
Michael Gehring 2015-01-09 14:09:12 +01:00
parent 3580c69d00
commit cb87309e92
2 changed files with 9 additions and 7 deletions

View file

@ -208,7 +208,9 @@ impl<'a> Searcher<'a> {
} }
} }
impl<'a> Iterator<(uint, uint)> for Searcher<'a> { impl<'a> Iterator for Searcher<'a> {
type Item = (uint, uint);
fn next(&mut self) -> Option<(uint, uint)> { fn next(&mut self) -> Option<(uint, uint)> {
if self.needle.len() == 1 { if self.needle.len() == 1 {
for offset in range(self.position, self.haystack.len()) { for offset in range(self.position, self.haystack.len()) {

View file

@ -23,19 +23,19 @@ impl std::str::FromStr for Range {
match (parts.next(), parts.next()) { match (parts.next(), parts.next()) {
(Some(nm), None) => { (Some(nm), None) => {
std::str::FromStr::from_str::<uint>(nm).and_then(|nm| if nm > 0 { Some(nm) } else { None }) nm.parse::<uint>().and_then(|nm| if nm > 0 { Some(nm) } else { None })
.map(|nm| Range { low: nm, high: nm }) .map(|nm| Range { low: nm, high: nm })
} }
(Some(n), Some(m)) if m.len() == 0 => { (Some(n), Some(m)) if m.len() == 0 => {
std::str::FromStr::from_str::<uint>(n).and_then(|low| if low > 0 { Some(low) } else { None }) n.parse::<uint>().and_then(|low| if low > 0 { Some(low) } else { None })
.map(|low| Range { low: low, high: MAX }) .map(|low| Range { low: low, high: MAX })
} }
(Some(n), Some(m)) if n.len() == 0 => { (Some(n), Some(m)) if n.len() == 0 => {
std::str::FromStr::from_str::<uint>(m).and_then(|high| if high >= 1 { Some(high) } else { None }) m.parse::<uint>().and_then(|high| if high >= 1 { Some(high) } else { None })
.map(|high| Range { low: 1, high: high }) .map(|high| Range { low: 1, high: high })
} }
(Some(n), Some(m)) => { (Some(n), Some(m)) => {
match (std::str::FromStr::from_str::<uint>(n), std::str::FromStr::from_str::<uint>(m)) { match (n.parse::<uint>(), m.parse::<uint>()) {
(Some(low), Some(high)) if low > 0 && low <= high => { (Some(low), Some(high)) if low > 0 && low <= high => {
Some(Range { low: low, high: high }) Some(Range { low: low, high: high })
} }
@ -51,7 +51,7 @@ impl Range {
pub fn from_list(list: &str) -> Result<Vec<Range>, String> { pub fn from_list(list: &str) -> Result<Vec<Range>, String> {
use std::cmp::max; use std::cmp::max;
let mut ranges = vec!(); let mut ranges : Vec<Range> = vec!();
for item in list.split(',') { for item in list.split(',') {
match std::str::FromStr::from_str(item) { match std::str::FromStr::from_str(item) {
@ -67,7 +67,7 @@ impl Range {
let j = i + 1; let j = i + 1;
while j < ranges.len() && ranges[j].low <= ranges[i].high { while j < ranges.len() && ranges[j].low <= ranges[i].high {
let j_high = ranges.remove(j).unwrap().high; let j_high = ranges.remove(j).high;
ranges[i].high = max(ranges[i].high, j_high); ranges[i].high = max(ranges[i].high, j_high);
} }
} }