Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'helix-core/src/selection.rs')
| -rw-r--r-- | helix-core/src/selection.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/helix-core/src/selection.rs b/helix-core/src/selection.rs index 76de6362..a134a06e 100644 --- a/helix-core/src/selection.rs +++ b/helix-core/src/selection.rs @@ -619,7 +619,6 @@ impl Selection { self } - // TODO: consume an iterator or a vec to reduce allocations? #[must_use] pub fn new(ranges: SmallVec<[Range; 1]>, primary_index: usize) -> Self { assert!(!ranges.is_empty()); @@ -721,6 +720,12 @@ impl IntoIterator for Selection { } } +impl FromIterator<Range> for Selection { + fn from_iter<T: IntoIterator<Item = Range>>(ranges: T) -> Self { + Self::new(ranges.into_iter().collect(), 0) + } +} + impl From<Range> for Selection { fn from(range: Range) -> Self { Self { |