save tree borrow lifetime in range/iter
This commit is contained in:
parent
e0b1ddf3f6
commit
a1a5b08970
|
@ -1,5 +1,6 @@
|
|||
use core::cell::Cell;
|
||||
use core::fmt::Display;
|
||||
use core::marker::PhantomData;
|
||||
use core::mem::size_of;
|
||||
use core::ops::Deref;
|
||||
|
||||
|
@ -166,10 +167,11 @@ impl Display for NodeHandle {
|
|||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Range<R: super::Read> {
|
||||
pub struct Range<'tree, R: super::Read> {
|
||||
volume: Rc<Volume<R>>,
|
||||
pub(crate) start: RootOrEdge,
|
||||
pub(crate) end: RootOrEdge,
|
||||
phantom: PhantomData<&'tree ()>,
|
||||
}
|
||||
|
||||
#[derive(Derivative)]
|
||||
|
@ -282,7 +284,7 @@ impl<R: super::Read> Tree<R> {
|
|||
))
|
||||
}
|
||||
|
||||
pub fn iter(&self) -> Range<R> {
|
||||
pub fn iter(&self) -> Range<'_, R> {
|
||||
Range::new(self.volume.clone(), self.root.clone(), self.root.clone())
|
||||
}
|
||||
}
|
||||
|
@ -572,7 +574,7 @@ impl Node {
|
|||
}
|
||||
}
|
||||
|
||||
impl<R> Range<R>
|
||||
impl<'tree, R> Range<'tree, R>
|
||||
where
|
||||
R: super::Read,
|
||||
{
|
||||
|
@ -581,6 +583,7 @@ where
|
|||
volume,
|
||||
start: RootOrEdge::Root(start),
|
||||
end: RootOrEdge::Root(end),
|
||||
phantom: PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -593,7 +596,7 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
impl<R> Iterator for Range<R>
|
||||
impl<'tree, R> Iterator for Range<'tree, R>
|
||||
where
|
||||
R: super::Read,
|
||||
{
|
||||
|
@ -620,7 +623,7 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
impl<R> DoubleEndedIterator for Range<R>
|
||||
impl<'tree, R> DoubleEndedIterator for Range<'tree, R>
|
||||
where
|
||||
R: super::Read,
|
||||
{
|
||||
|
|
|
@ -371,15 +371,13 @@ impl<R: super::Read> Fs<R> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn get_inode_children_inodes<'a>(
|
||||
pub fn get_inode_children_inodes(
|
||||
&self,
|
||||
inode: &'a INode,
|
||||
) -> Result<impl Iterator<Item = INode> + 'a>
|
||||
where
|
||||
R: 'a,
|
||||
{
|
||||
self.get_inode_children(inode).map(|children| {
|
||||
children.map(|child| {
|
||||
inode: &INode,
|
||||
) -> Result<impl Iterator<Item = INode> + '_> {
|
||||
let inode = inode.clone();
|
||||
self.get_inode_children(&inode).map(|children| {
|
||||
children.map(move |child| {
|
||||
let id: u64 = child.item().location.id().into();
|
||||
|
||||
inode.clone().into_child(id, child.into_name())
|
||||
|
@ -387,7 +385,10 @@ impl<R: super::Read> Fs<R> {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn get_inode_children(&self, inode: &INode) -> Result<impl Iterator<Item = DirItemEntry>> {
|
||||
pub fn get_inode_children(
|
||||
&self,
|
||||
inode: &INode,
|
||||
) -> Result<impl Iterator<Item = DirItemEntry> + '_> {
|
||||
let key = PartialKey::new(Some(inode.id()), Some(ObjectType::DirIndex), None);
|
||||
|
||||
let children = self.fs_root.find_range(&key)?;
|
||||
|
|
Loading…
Reference in a new issue