dioxus/packages/core/src/bump_frame.rs

25 lines
468 B
Rust
Raw Normal View History

use std::cell::Cell;
use bumpalo::Bump;
2022-11-02 01:42:29 +00:00
use crate::nodes::VNode;
pub struct BumpFrame {
pub bump: Bump,
2022-11-02 01:42:29 +00:00
pub node: Cell<*const VNode<'static>>,
}
impl BumpFrame {
pub fn new(capacity: usize) -> Self {
let bump = Bump::with_capacity(capacity);
Self {
bump,
node: Cell::new(std::ptr::null()),
}
}
pub fn reset(&mut self) {
self.bump.reset();
self.node.set(std::ptr::null());
}
}