Skip to content

armgit / uzu

Public Imported from GitHub
0

A high-performance inference engine for AI models

333 B
Raw Blame
pub struct Deferred<T> {
    slot: Option<T>,
    init: fn() -> T,
}

impl<T> Deferred<T> {
    pub const fn new(init: fn() -> T) -> Self {
        Self {
            slot: None,
            init,
        }
    }

    pub fn get(&mut self) -> &mut T {
        let init = self.init;
        self.slot.get_or_insert_with(init)
    }
}