After some discussion with PVH I realise that the repo structure in the last reorg was very rust-centric. In an attempt to put each language on a level footing move the rust code and project files into ./rust
36 lines
999 B
Rust
36 lines
999 B
Rust
use crate::{exid::ExId, Value};
|
|
use std::ops::RangeBounds;
|
|
|
|
use crate::{query, Automerge};
|
|
|
|
#[derive(Debug)]
|
|
pub struct MapRangeAt<'a, R: RangeBounds<String>> {
|
|
range: Option<query::MapRangeAt<'a, R>>,
|
|
doc: &'a Automerge,
|
|
}
|
|
|
|
impl<'a, R: RangeBounds<String>> MapRangeAt<'a, R> {
|
|
pub(crate) fn new(doc: &'a Automerge, range: Option<query::MapRangeAt<'a, R>>) -> Self {
|
|
Self { range, doc }
|
|
}
|
|
}
|
|
|
|
impl<'a, R: RangeBounds<String>> Iterator for MapRangeAt<'a, R> {
|
|
type Item = (&'a str, Value<'a>, ExId);
|
|
|
|
fn next(&mut self) -> Option<Self::Item> {
|
|
self.range
|
|
.as_mut()?
|
|
.next()
|
|
.map(|(key, value, id)| (key, value, self.doc.id_to_exid(id)))
|
|
}
|
|
}
|
|
|
|
impl<'a, R: RangeBounds<String>> DoubleEndedIterator for MapRangeAt<'a, R> {
|
|
fn next_back(&mut self) -> Option<Self::Item> {
|
|
self.range
|
|
.as_mut()?
|
|
.next_back()
|
|
.map(|(key, value, id)| (key, value, self.doc.id_to_exid(id)))
|
|
}
|
|
}
|