Skip to content

Commit

Permalink
Replaced list::each with iter() in get_region
Browse files Browse the repository at this point in the history
  • Loading branch information
brunoabinader committed Feb 27, 2014
1 parent 0c8731e commit 43bc6fc
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions src/librustc/middle/typeck/mod.rs
Expand Up @@ -73,7 +73,6 @@ use std::cell::RefCell;
use collections::HashMap;
use std::rc::Rc;
use collections::List;
use collections::list;
use syntax::codemap::Span;
use syntax::print::pprust::*;
use syntax::{ast, ast_map, abi};
Expand Down Expand Up @@ -311,23 +310,18 @@ pub fn require_same_types(tcx: ty::ctxt,
// corresponding ty::Region
pub type isr_alist = @List<(ty::BoundRegion, ty::Region)>;

trait get_and_find_region {
fn get(&self, br: ty::BoundRegion) -> ty::Region;
fn find(&self, br: ty::BoundRegion) -> Option<ty::Region>;
trait get_region<'a, T:'static> {
fn get(&'a self, br: ty::BoundRegion) -> ty::Region;
}

impl get_and_find_region for isr_alist {
fn get(&self, br: ty::BoundRegion) -> ty::Region {
self.find(br).unwrap()
}

fn find(&self, br: ty::BoundRegion) -> Option<ty::Region> {
let mut ret = None;
list::each(*self, |isr| {
impl<'a, T:'static> get_region <'a, T> for isr_alist {
fn get(&'a self, br: ty::BoundRegion) -> ty::Region {
let mut region = None;
for isr in self.iter() {
let (isr_br, isr_r) = *isr;
if isr_br == br { ret = Some(isr_r); false } else { true }
});
ret
if isr_br == br { region = Some(isr_r); break; }
};
region.unwrap()
}
}

Expand Down

0 comments on commit 43bc6fc

Please sign in to comment.