rendy_util

Function identical_cast

Source
pub fn identical_cast<T: 'static, U: 'static>(value: T) -> U
Expand description

Casts identical types. Useful in generic environment where caller knows that two types are the same but Rust is not convinced.

§Panics

Panics if types are actually different.

§Example

if TypeId::of::<T>() == TypeId::of::<u32>() {
    let value: T = identical_cast(42u32);
}