Make SelectionsCollection::disjoint_anchor_ranges
return an iterator (#22948)
This helps discourage unnecessary collection to Vec Release Notes: - N/A
This commit is contained in:
parent
690ad29ba9
commit
1b44398967
4 changed files with 24 additions and 31 deletions
|
@ -88,6 +88,12 @@ impl SelectionsCollection {
|
|||
self.disjoint.clone()
|
||||
}
|
||||
|
||||
pub fn disjoint_anchor_ranges(&self) -> impl Iterator<Item = Range<Anchor>> {
|
||||
// Mapping the Arc slice would borrow it, whereas indexing captures it.
|
||||
let disjoint = self.disjoint_anchors();
|
||||
(0..disjoint.len()).map(move |ix| disjoint[ix].range())
|
||||
}
|
||||
|
||||
pub fn pending_anchor(&self) -> Option<Selection<Anchor>> {
|
||||
self.pending
|
||||
.as_ref()
|
||||
|
@ -317,13 +323,6 @@ impl SelectionsCollection {
|
|||
self.all(cx).last().unwrap().clone()
|
||||
}
|
||||
|
||||
pub fn disjoint_anchor_ranges(&self) -> Vec<Range<Anchor>> {
|
||||
self.disjoint_anchors()
|
||||
.iter()
|
||||
.map(|s| s.start..s.end)
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[cfg(any(test, feature = "test-support"))]
|
||||
pub fn ranges<D: TextDimension + Ord + Sub<D, Output = D> + std::fmt::Debug>(
|
||||
&self,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue