Implement anchors using an offset + a version vector

This commit is contained in:
Antonio Scandurra
2021-06-01 15:28:20 +02:00
parent 311e1b0f5e
commit da7e3c8cd8
4 changed files with 273 additions and 293 deletions
+11 -2
View File
@@ -1,5 +1,5 @@
use super::{Buffer, ToOffset};
use crate::time;
use crate::{sum_tree, time};
use anyhow::Result;
use std::{cmp::Ordering, ops::Range};
@@ -14,12 +14,21 @@ pub enum Anchor {
},
}
#[derive(Clone, Eq, PartialEq, Debug, Hash)]
#[derive(Copy, Clone, Eq, PartialEq, Debug, Hash)]
pub enum AnchorBias {
Left,
Right,
}
impl AnchorBias {
pub fn to_seek_bias(self) -> sum_tree::SeekBias {
match self {
AnchorBias::Left => sum_tree::SeekBias::Left,
AnchorBias::Right => sum_tree::SeekBias::Right,
}
}
}
impl PartialOrd for AnchorBias {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))