Replace Default trait bound with a zero function on Summary/Dimension (#17975)
This lets us provide a context when constructing the zero value. We need it so we can require anchors to be associated with a buffer id, which we're doing as part of simplifying the multibuffer API. Release Notes: - N/A Co-authored-by: Nathan <nathan@zed.dev>
This commit is contained in:
parent
4d074fc737
commit
2e72fd210a
28 changed files with 706 additions and 349 deletions
|
@ -34,7 +34,7 @@ impl<T: Operation> Default for OperationQueue<T> {
|
|||
|
||||
impl<T: Operation> OperationQueue<T> {
|
||||
pub fn new() -> Self {
|
||||
OperationQueue(SumTree::new())
|
||||
OperationQueue(SumTree::default())
|
||||
}
|
||||
|
||||
pub fn len(&self) -> usize {
|
||||
|
@ -58,7 +58,7 @@ impl<T: Operation> OperationQueue<T> {
|
|||
|
||||
pub fn drain(&mut self) -> Self {
|
||||
let clone = self.clone();
|
||||
self.0 = SumTree::new();
|
||||
self.0 = SumTree::default();
|
||||
clone
|
||||
}
|
||||
|
||||
|
@ -70,6 +70,10 @@ impl<T: Operation> OperationQueue<T> {
|
|||
impl Summary for OperationSummary {
|
||||
type Context = ();
|
||||
|
||||
fn zero(_cx: &()) -> Self {
|
||||
Default::default()
|
||||
}
|
||||
|
||||
fn add_summary(&mut self, other: &Self, _: &()) {
|
||||
assert!(self.key < other.key);
|
||||
self.key = other.key;
|
||||
|
@ -90,6 +94,10 @@ impl<'a> Add<&'a Self> for OperationSummary {
|
|||
}
|
||||
|
||||
impl<'a> Dimension<'a, OperationSummary> for OperationKey {
|
||||
fn zero(_cx: &()) -> Self {
|
||||
Default::default()
|
||||
}
|
||||
|
||||
fn add_summary(&mut self, summary: &OperationSummary, _: &()) {
|
||||
assert!(*self <= summary.key);
|
||||
*self = summary.key;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue