auto merge of #1864 : saneyuki/servo/split_cast_to, r=jdm

fix #1836
This commit is contained in:
bors-servo 2014-03-20 10:58:36 -04:00
commit 8317122068
10 changed files with 71 additions and 64 deletions

View file

@ -5793,9 +5793,16 @@ class GlobalGenRoots():
unsafe { derived.clone().transmute() }
}
fn to<T: ${toBound}>(base: &JS<T>) -> JS<Self> {
fn to<T: ${toBound}>(base: &JS<T>) -> Option<JS<Self>> {
match base.get().${checkFn}() {
true => unsafe { Some(base.clone().transmute()) },
false => None
}
}
unsafe fn to_unchecked<T: ${toBound}>(base: &JS<T>) -> JS<Self> {
assert!(base.get().${checkFn}());
unsafe { base.clone().transmute() }
base.clone().transmute()
}
}
''').substitute({'checkFn': 'is_' + name.lower(),