wip: bubbling in progress
This commit is contained in:
1 parent
8acdd2ea83
commit
a21020ea57
15 files changed
+268
-291
No files matched your search
@@ -20,7 +20,7 @@ use std::mem;
|
||||
/// closures, but if we wrap the closure in a concrete type, we can maintain separate implementations of IntoVNode.
|
||||
///
|
||||
///
|
||||
/// ```rust
|
||||
/// ```rust, ignore
|
||||
/// LazyNodes::new(|f| f.element("div", [], [], [] None))
|
||||
/// ```
|
||||
pub struct LazyNodes<'a, 'b> {
|
||||
@@ -47,7 +47,14 @@ impl<'a, 'b> LazyNodes<'a, 'b> {
|
||||
fac.map(inner)
|
||||
};
|
||||
|
||||
unsafe { LazyNodes::new_inner(val) }
|
||||
// miri does not know how to work with mucking directly into bytes
|
||||
if cfg!(miri) {
|
||||
Self {
|
||||
inner: StackNodeStorage::Heap(Box::new(val)),
|
||||
}
|
||||
} else {
|
||||
unsafe { LazyNodes::new_inner(val) }
|
||||
}
|
||||
}
|
||||
|
||||
unsafe fn new_inner<F>(val: F) -> Self
|
||||
@@ -212,6 +219,7 @@ fn round_to_words(len: usize) -> usize {
|
||||
fn it_works() {
|
||||
let bump = bumpalo::Bump::new();
|
||||
|
||||
#[cfg(not(miri))]
|
||||
simple_logger::init().unwrap();
|
||||
|
||||
let factory = NodeFactory { bump: &bump };
|
||||
@@ -232,9 +240,10 @@ fn it_drops() {
|
||||
use std::rc::Rc;
|
||||
let bump = bumpalo::Bump::new();
|
||||
|
||||
#[cfg(not(miri))]
|
||||
simple_logger::init().unwrap();
|
||||
|
||||
// let factory = NodeFactory { scope: &bump };
|
||||
let factory = NodeFactory { bump: &bump };
|
||||
|
||||
struct DropInner {
|
||||
id: i32,
|
||||
@@ -246,7 +255,7 @@ fn it_drops() {
|
||||
}
|
||||
let val = Rc::new(10);
|
||||
|
||||
{
|
||||
let caller = {
|
||||
let it = (0..10)
|
||||
.map(|i| {
|
||||
let val = val.clone();
|
||||
@@ -259,16 +268,13 @@ fn it_drops() {
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let caller = NodeFactory::annotate_lazy(|f| {
|
||||
NodeFactory::annotate_lazy(|f| {
|
||||
log::debug!("main closure");
|
||||
f.fragment_from_iter(it)
|
||||
})
|
||||
.unwrap();
|
||||
}
|
||||
.unwrap()
|
||||
};
|
||||
|
||||
// let nodes = caller.call(factory);
|
||||
|
||||
// dbg!(nodes);
|
||||
|
||||
dbg!(Rc::strong_count(&val));
|
||||
let _ = caller.call(factory);
|
||||
assert_eq!(Rc::strong_count(&val), 1);
|
||||
}
|
||||
Reference in new issue
Block a user