mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-12-21 18:13:15 +00:00
29 lines
676 B
Rust
29 lines
676 B
Rust
use crate::nodes::RenderReturn;
|
|
use bumpalo::Bump;
|
|
use std::cell::Cell;
|
|
|
|
pub(crate) struct BumpFrame {
|
|
pub bump: Bump,
|
|
pub node: Cell<*const RenderReturn<'static>>,
|
|
}
|
|
|
|
impl BumpFrame {
|
|
pub(crate) fn new(capacity: usize) -> Self {
|
|
let bump = Bump::with_capacity(capacity);
|
|
Self {
|
|
bump,
|
|
node: Cell::new(std::ptr::null()),
|
|
}
|
|
}
|
|
|
|
/// Creates a new lifetime out of thin air
|
|
pub(crate) unsafe fn try_load_node<'b>(&self) -> Option<&'b RenderReturn<'b>> {
|
|
let node = self.node.get();
|
|
|
|
if node.is_null() {
|
|
return None;
|
|
}
|
|
|
|
unsafe { std::mem::transmute(&*node) }
|
|
}
|
|
}
|