Skip to content

Commit 7c88057

Browse files
committed
add last method to segment list
1 parent 78fae69 commit 7c88057

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

libsql-wal/src/segment/list.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,23 @@ where
265265

266266
(tokio_util::either::Either::Right(stream), new_current)
267267
}
268+
269+
pub(crate) fn last(&self) -> Option<Seg>
270+
where Seg: Clone,
271+
{
272+
let mut current = self.list.head.load().clone();
273+
loop {
274+
match current.as_ref() {
275+
Some(c) => {
276+
if c.next.load().is_none() {
277+
return Some(c.item.clone())
278+
}
279+
current = c.next.load().clone();
280+
},
281+
None => return None,
282+
}
283+
}
284+
}
268285
}
269286

270287
struct Node<T> {

0 commit comments

Comments
 (0)