use crate::tree;
use crate::tree::NodeId;
#[derive(Copy, Clone, Debug)]
pub enum Location<Key> {
AfterSibling(Key),
FirstChildOf(Key),
}
impl<Key> Location<Key> {
pub(crate) fn into_tree_location<E>(
self,
mapper: impl FnOnce(Key) -> Result<NodeId, E>,
) -> Result<tree::Location, E> {
Ok(match self {
Location::AfterSibling(id) => tree::Location::AfterSibling((mapper)(id)?),
Location::FirstChildOf(id) => tree::Location::FirstChildOf((mapper)(id)?),
})
}
}