#[cfg(doc)]
use crate::zipper::*;
pub use pathmap_derive::PolyZipper;
pub use pathmap_derive::PolyZipperExplicit;
#[cfg(test)]
mod tests {
use crate as pathmap;
use crate::PathMap;
use crate::zipper::*;
#[cfg(feature = "arena_compact")]
use crate::arena_compact::{ACTMmapZipper, ACTVecZipper, ACTVec};
#[cfg(not(feature = "arena_compact"))]
#[derive(PolyZipper)]
pub enum TestPolyZipper<'trie, V: Clone + Send + Sync + Unpin = ()> {
PathMap(ReadZipperTracked<'trie, 'trie, V>),
PathMapU(ReadZipperUntracked<'trie, 'trie, V>),
}
#[cfg(feature = "arena_compact")]
#[derive(PolyZipper)]
pub enum TestPolyZipper<'trie, V: Clone + Send + Sync + Unpin = ()> {
PathMap(ReadZipperTracked<'trie, 'trie, V>),
PathMapU(ReadZipperUntracked<'trie, 'trie, V>),
ACTMmapPrefix(PrefixZipper<'trie, ACTMmapZipper<'trie, V>>),
ACTVecPrefix(PrefixZipper<'trie, ACTVecZipper<'trie, V>>),
}
crate::zipper::zipper_moving_tests::zipper_moving_tests!(poly_zipper_pm,
|keys: &[&[u8]]| {
keys.iter().map(|k| (k, ())).collect::<PathMap<()>>()
},
|btm: &mut PathMap<()>, path: &[u8]| -> _ {
TestPolyZipper::PathMapU(btm.read_zipper_at_path(path))
}
);
crate::zipper::zipper_iteration_tests::zipper_iteration_tests!(poly_zipper_pm,
|keys: &[&[u8]]| {
keys.iter().map(|k| (k, ())).collect::<PathMap<()>>()
},
|btm: &mut PathMap<()>, path: &[u8]| -> _ {
TestPolyZipper::PathMapU(btm.read_zipper_at_path(path))
}
);
#[cfg(feature = "arena_compact")]
crate::zipper::zipper_moving_tests::zipper_moving_tests!(poly_zipper_act,
|keys: &[&[u8]]| {
let btm = keys.iter().map(|k| (k, ())).collect::<PathMap<()>>();
ACTVec::from_zipper(btm.read_zipper(), |()| 0)
},
|act: &mut ACTVec, path: &[u8]| -> _ {
TestPolyZipper::ACTVecPrefix(PrefixZipper::new(&[], act.read_zipper_at_path(path)))
}
);
#[cfg(feature = "arena_compact")]
crate::zipper::zipper_iteration_tests::zipper_iteration_tests!(poly_zipper_act,
|keys: &[&[u8]]| {
let btm = keys.iter().map(|k| (k, ())).collect::<PathMap<()>>();
ACTVec::from_zipper(btm.read_zipper(), |()| 0)
},
|act: &mut ACTVec, path: &[u8]| -> _ {
TestPolyZipper::ACTVecPrefix(PrefixZipper::new(&[], act.read_zipper_at_path(path)))
}
);
#[derive(PolyZipperExplicit)]
#[poly_zipper_explicit(traits(Zipper, ZipperValues, ZipperMoving, ZipperIteration))]
pub enum ExprFactor<'trie, V: Clone + Send + Sync + Unpin + 'static = ()> {
Specific(ReadZipperOwned<V>),
Generic(PrefixZipper<'trie,
DependentProductZipperG<'trie,
Box<ExprFactor<'trie, V>>,
ExprFactor<'trie, V>,
V, (),
for<'a> fn((), &'a [u8], usize) -> ((), Option< ExprFactor<'trie, V> >)
>>
)
}
crate::zipper::zipper_moving_tests::zipper_moving_tests!(recursive_zipper_madness,
|keys: &[&[u8]]| {
keys.iter().map(|k| (k, ())).collect::<PathMap<()>>()
},
|btm: &mut PathMap<()>, path: &[u8]| -> _ {
ExprFactor::Specific(btm.clone().into_read_zipper(path))
}
);
}