Annotate 'inline' to TCast::to/to_unchecked/from.

This commit is contained in:
Tetsuharu OHZEKI 2014-03-21 01:09:36 +09:00
parent de67069b0a
commit cfb2af60d8

View file

@ -5745,10 +5745,12 @@ class GlobalGenRoots():
derived += [CGGeneric('\n')] derived += [CGGeneric('\n')]
cast = [CGGeneric(string.Template('''pub trait ${castTraitName} { cast = [CGGeneric(string.Template('''pub trait ${castTraitName} {
#[inline(always)]
fn from<T: ${fromBound}>(derived: &JS<T>) -> JS<Self> { fn from<T: ${fromBound}>(derived: &JS<T>) -> JS<Self> {
unsafe { derived.clone().transmute() } unsafe { derived.clone().transmute() }
} }
#[inline(always)]
fn to<T: ${toBound}>(base: &JS<T>) -> Option<JS<Self>> { fn to<T: ${toBound}>(base: &JS<T>) -> Option<JS<Self>> {
match base.get().${checkFn}() { match base.get().${checkFn}() {
true => unsafe { Some(base.clone().transmute()) }, true => unsafe { Some(base.clone().transmute()) },
@ -5756,6 +5758,7 @@ class GlobalGenRoots():
} }
} }
#[inline(always)]
unsafe fn to_unchecked<T: ${toBound}>(base: &JS<T>) -> JS<Self> { unsafe fn to_unchecked<T: ${toBound}>(base: &JS<T>) -> JS<Self> {
assert!(base.get().${checkFn}()); assert!(base.get().${checkFn}());
base.clone().transmute() base.clone().transmute()