sum_tree: Remove Unit type (#35027)
This solves one ~TODO, as Unit type was a workaround for a lack of ability to implement Summary for (). Release Notes: - N/A
This commit is contained in:
parent
0af690080b
commit
1e2b0fcab6
2 changed files with 9 additions and 17 deletions
|
@ -41,16 +41,14 @@ pub trait Summary: Clone {
|
||||||
fn add_summary(&mut self, summary: &Self, cx: &Self::Context);
|
fn add_summary(&mut self, summary: &Self, cx: &Self::Context);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This type exists because we can't implement Summary for () without causing
|
/// Catch-all implementation for when you need something that implements [`Summary`] without a specific type.
|
||||||
/// type resolution errors
|
/// We implement it on a &'static, as that avoids blanket impl collisions with `impl<T: Summary> Dimension for T`
|
||||||
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
|
/// (as we also need unit type to be a fill-in dimension)
|
||||||
pub struct Unit;
|
impl Summary for &'static () {
|
||||||
|
|
||||||
impl Summary for Unit {
|
|
||||||
type Context = ();
|
type Context = ();
|
||||||
|
|
||||||
fn zero(_: &()) -> Self {
|
fn zero(_: &()) -> Self {
|
||||||
Unit
|
&()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_summary(&mut self, _: &Self, _: &()) {}
|
fn add_summary(&mut self, _: &Self, _: &()) {}
|
||||||
|
|
|
@ -62,7 +62,7 @@ use std::{
|
||||||
},
|
},
|
||||||
time::{Duration, Instant},
|
time::{Duration, Instant},
|
||||||
};
|
};
|
||||||
use sum_tree::{Bias, Edit, KeyedItem, SeekTarget, SumTree, Summary, TreeMap, TreeSet, Unit};
|
use sum_tree::{Bias, Edit, KeyedItem, SeekTarget, SumTree, Summary, TreeMap, TreeSet};
|
||||||
use text::{LineEnding, Rope};
|
use text::{LineEnding, Rope};
|
||||||
use util::{
|
use util::{
|
||||||
ResultExt,
|
ResultExt,
|
||||||
|
@ -407,12 +407,12 @@ struct LocalRepositoryEntry {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl sum_tree::Item for LocalRepositoryEntry {
|
impl sum_tree::Item for LocalRepositoryEntry {
|
||||||
type Summary = PathSummary<Unit>;
|
type Summary = PathSummary<&'static ()>;
|
||||||
|
|
||||||
fn summary(&self, _: &<Self::Summary as Summary>::Context) -> Self::Summary {
|
fn summary(&self, _: &<Self::Summary as Summary>::Context) -> Self::Summary {
|
||||||
PathSummary {
|
PathSummary {
|
||||||
max_path: self.work_directory.path_key().0,
|
max_path: self.work_directory.path_key().0,
|
||||||
item_summary: Unit,
|
item_summary: &(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -425,12 +425,6 @@ impl KeyedItem for LocalRepositoryEntry {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//impl LocalRepositoryEntry {
|
|
||||||
// pub fn repo(&self) -> &Arc<dyn GitRepository> {
|
|
||||||
// &self.repo_ptr
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
impl Deref for LocalRepositoryEntry {
|
impl Deref for LocalRepositoryEntry {
|
||||||
type Target = WorkDirectory;
|
type Target = WorkDirectory;
|
||||||
|
|
||||||
|
@ -5417,7 +5411,7 @@ impl<'a> SeekTarget<'a, EntrySummary, TraversalProgress<'a>> for TraversalTarget
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> SeekTarget<'a, PathSummary<Unit>, TraversalProgress<'a>> for TraversalTarget<'_> {
|
impl<'a> SeekTarget<'a, PathSummary<&'static ()>, TraversalProgress<'a>> for TraversalTarget<'_> {
|
||||||
fn cmp(&self, cursor_location: &TraversalProgress<'a>, _: &()) -> Ordering {
|
fn cmp(&self, cursor_location: &TraversalProgress<'a>, _: &()) -> Ordering {
|
||||||
self.cmp_progress(cursor_location)
|
self.cmp_progress(cursor_location)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue