Skip to content

Commit e712ad8

Browse files
committed
rewrite lookup_method(), lookup_method_inner(), and lookup_method_inner_()
1 parent 3e6943d commit e712ad8

File tree

3 files changed

+313
-302
lines changed

3 files changed

+313
-302
lines changed

src/libcore/option.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,15 @@ impl extensions<T:copy> for option<T> {
100100
{ map_default(self, def, f) }
101101
#[doc = "Performs an operation on the contained value or does nothing"]
102102
fn iter(f: fn(T)) { iter(self, f) }
103+
104+
#[doc = "Performs an operation on the contained value or does nothing"]
105+
fn each(f: fn(T) -> bool) {
106+
alt self {
107+
none { /* ok */ }
108+
some(e) { f(e); }
109+
}
110+
}
111+
103112
#[doc = "
104113
Gets the value out of an option
105114

src/rustc/middle/ty.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -807,10 +807,11 @@ fn fold_region(cx: ctxt, t0: t, fldop: fn(region, bool) -> region) -> t {
807807
}
808808

809809
fn substitute_type_params(cx: ctxt, substs: [ty::t], typ: t) -> t {
810+
if substs.len() == 0u { ret typ; }
810811
let tb = get(typ);
812+
if !tb.has_params { ret typ; }
811813
alt tb.struct {
812814
ty_param(idx, _) { substs[idx] }
813-
_ if !tb.has_params { typ }
814815
s { mk_t(cx, fold_sty(s) {|t| substitute_type_params(cx, substs, t)}) }
815816
}
816817
}

0 commit comments

Comments
 (0)