Skip to content

armgit / uzu

Public Imported from GitHub
0

A high-performance inference engine for AI models

262 B
Raw Blame
use std::any::{Any, TypeId};

#[inline]
pub fn downcast_ref<U: Any>(value: &(impl Any + ?Sized)) -> Option<&U> {
    if Any::type_id(value) == TypeId::of::<U>() {
        Some(unsafe { &*std::ptr::from_ref(value).cast::<U>() })
    } else {
        None
    }
}