difftreelog
perf inline trivial IntoUntyped
in: master
1 file changed
crates/jrsonnet-evaluator/src/typed/conversions.rsdiffbeforeafterboth134 const TYPE: &'static ComplexValType = &ComplexValType::Lazy(T::TYPE);134 const TYPE: &'static ComplexValType = &ComplexValType::Lazy(T::TYPE);135}135}136136137#[inline]137fn try_cast_thunk_val<T: 'static>(typed: Thunk<T>) -> Result<Thunk<Val>, Thunk<T>> {138fn try_cast_thunk_val<T: 'static>(typed: Thunk<T>) -> Result<Thunk<Val>, Thunk<T>> {138 if TypeId::of::<T>() == TypeId::of::<Val>() {139 if TypeId::of::<T>() == TypeId::of::<Val>() {139 // SAFETY: We know that it is exactly the same type, and we discard the original after that140 // SAFETY: We know that it is exactly the same type, and we discard the original after that148where149where149 T: IntoUntyped + Trace + Clone,150 T: IntoUntyped + Trace + Clone,150{151{152 #[inline]151 fn into_untyped(typed: Self) -> Result<Val> {153 fn into_untyped(typed: Self) -> Result<Val> {152 T::into_untyped(typed.evaluate()?)154 T::into_untyped(typed.evaluate()?)153 }155 }185 }187 }186}188}187189190#[inline]188fn try_cast_thunk_t<T: 'static>(typed: Thunk<Val>) -> Result<Thunk<T>, Thunk<Val>> {191fn try_cast_thunk_t<T: 'static>(typed: Thunk<Val>) -> Result<Thunk<T>, Thunk<Val>> {189 if TypeId::of::<T>() == TypeId::of::<Val>() {192 if TypeId::of::<T>() == TypeId::of::<Val>() {190 // SAFETY: We know that it is exactly the same type, and we discard the original after that193 // SAFETY: We know that it is exactly the same type, and we discard the original after that581 const TYPE: &'static ComplexValType = &ComplexValType::Any;584 const TYPE: &'static ComplexValType = &ComplexValType::Any;582}585}583impl IntoUntyped for &Val {586impl IntoUntyped for &Val {587 #[inline]584 fn into_untyped(typed: Self) -> Result<Val> {588 fn into_untyped(typed: Self) -> Result<Val> {585 Ok(typed.clone())589 Ok(typed.clone())586 }590 }587}591}588impl IntoUntyped for Val {592impl IntoUntyped for Val {593 #[inline]589 fn into_untyped(typed: Self) -> Result<Val> {594 fn into_untyped(typed: Self) -> Result<Val> {590 Ok(typed)595 Ok(typed)591 }596 }