Skip to content

Commit 43bc6fc

Browse files
committed
Replaced list::each with iter() in get_region
1 parent 0c8731e commit 43bc6fc

File tree

1 file changed

+9
-15
lines changed
  • src/librustc/middle/typeck

1 file changed

+9
-15
lines changed

src/librustc/middle/typeck/mod.rs

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ use std::cell::RefCell;
7373
use collections::HashMap;
7474
use std::rc::Rc;
7575
use collections::List;
76-
use collections::list;
7776
use syntax::codemap::Span;
7877
use syntax::print::pprust::*;
7978
use syntax::{ast, ast_map, abi};
@@ -311,23 +310,18 @@ pub fn require_same_types(tcx: ty::ctxt,
311310
// corresponding ty::Region
312311
pub type isr_alist = @List<(ty::BoundRegion, ty::Region)>;
313312

314-
trait get_and_find_region {
315-
fn get(&self, br: ty::BoundRegion) -> ty::Region;
316-
fn find(&self, br: ty::BoundRegion) -> Option<ty::Region>;
313+
trait get_region<'a, T:'static> {
314+
fn get(&'a self, br: ty::BoundRegion) -> ty::Region;
317315
}
318316

319-
impl get_and_find_region for isr_alist {
320-
fn get(&self, br: ty::BoundRegion) -> ty::Region {
321-
self.find(br).unwrap()
322-
}
323-
324-
fn find(&self, br: ty::BoundRegion) -> Option<ty::Region> {
325-
let mut ret = None;
326-
list::each(*self, |isr| {
317+
impl<'a, T:'static> get_region <'a, T> for isr_alist {
318+
fn get(&'a self, br: ty::BoundRegion) -> ty::Region {
319+
let mut region = None;
320+
for isr in self.iter() {
327321
let (isr_br, isr_r) = *isr;
328-
if isr_br == br { ret = Some(isr_r); false } else { true }
329-
});
330-
ret
322+
if isr_br == br { region = Some(isr_r); break; }
323+
};
324+
region.unwrap()
331325
}
332326
}
333327

0 commit comments

Comments
 (0)