diff options
author | Joe Wilm <jwilm@users.noreply.github.com> | 2018-12-10 09:53:56 -0800 |
---|---|---|
committer | Christian Duerr <chrisduerr@users.noreply.github.com> | 2018-12-10 17:53:56 +0000 |
commit | 217ad9ec285b4923de1790b0976c8c793039c994 (patch) | |
tree | 440e0d6d35f119246d2b113fd01b431f4f9c2c38 /src/grid | |
parent | 7ab0b448479c9705fa14003bda97040630710b7a (diff) | |
download | alacritty-217ad9ec285b4923de1790b0976c8c793039c994.tar.gz alacritty-217ad9ec285b4923de1790b0976c8c793039c994.zip |
Upgrade to Rust 2018
This resolves a lot of NLL issues, however full NLL will be necessary to
handle a couple of remaining issues.
Diffstat (limited to 'src/grid')
-rw-r--r-- | src/grid/mod.rs | 40 | ||||
-rw-r--r-- | src/grid/row.rs | 4 | ||||
-rw-r--r-- | src/grid/storage.rs | 9 | ||||
-rw-r--r-- | src/grid/tests.rs | 2 |
4 files changed, 28 insertions, 27 deletions
diff --git a/src/grid/mod.rs b/src/grid/mod.rs index 113445af..a00fed40 100644 --- a/src/grid/mod.rs +++ b/src/grid/mod.rs @@ -17,8 +17,8 @@ use std::cmp::{min, max, Ordering}; use std::ops::{Deref, Range, Index, IndexMut, RangeTo, RangeFrom, RangeFull}; -use index::{self, Point, Line, Column, IndexRange}; -use selection::Selection; +use crate::index::{self, Point, Line, Column, IndexRange}; +use crate::selection::Selection; mod row; pub use self::row::Row; @@ -99,7 +99,7 @@ pub struct Grid<T> { max_scroll_limit: usize, } -pub struct GridIterator<'a, T: 'a> { +pub struct GridIterator<'a, T> { /// Immutable grid reference grid: &'a Grid<T>, @@ -411,7 +411,7 @@ impl<T> Grid<T> { self.lines } - pub fn display_iter(&self) -> DisplayIter<T> { + pub fn display_iter(&self) -> DisplayIter<'_, T> { DisplayIter::new(self) } @@ -454,7 +454,7 @@ impl<T> Grid<T> { self.raw.truncate(); } - pub fn iter_from(&self, point: Point<usize>) -> GridIterator<T> { + pub fn iter_from(&self, point: Point<usize>) -> GridIterator<'_, T> { GridIterator { grid: self, cur: point, @@ -557,7 +557,7 @@ impl<'point, T> IndexMut<&'point Point> for Grid<T> { /// A subset of lines in the grid /// /// May be constructed using Grid::region(..) -pub struct Region<'a, T: 'a> { +pub struct Region<'a, T> { start: Line, end: Line, raw: &'a Storage<T>, @@ -566,7 +566,7 @@ pub struct Region<'a, T: 'a> { /// A mutable subset of lines in the grid /// /// May be constructed using Grid::region_mut(..) -pub struct RegionMut<'a, T: 'a> { +pub struct RegionMut<'a, T> { start: Line, end: Line, raw: &'a mut Storage<T>, @@ -585,14 +585,14 @@ impl<'a, T> RegionMut<'a, T> { pub trait IndexRegion<I, T> { /// Get an immutable region of Self - fn region(&self, _: I) -> Region<T>; + fn region(&self, _: I) -> Region<'_, T>; /// Get a mutable region of Self - fn region_mut(&mut self, _: I) -> RegionMut<T>; + fn region_mut(&mut self, _: I) -> RegionMut<'_, T>; } impl<T> IndexRegion<Range<Line>, T> for Grid<T> { - fn region(&self, index: Range<Line>) -> Region<T> { + fn region(&self, index: Range<Line>) -> Region<'_, T> { assert!(index.start < self.num_lines()); assert!(index.end <= self.num_lines()); assert!(index.start <= index.end); @@ -602,7 +602,7 @@ impl<T> IndexRegion<Range<Line>, T> for Grid<T> { raw: &self.raw } } - fn region_mut(&mut self, index: Range<Line>) -> RegionMut<T> { + fn region_mut(&mut self, index: Range<Line>) -> RegionMut<'_, T> { assert!(index.start < self.num_lines()); assert!(index.end <= self.num_lines()); assert!(index.start <= index.end); @@ -615,7 +615,7 @@ impl<T> IndexRegion<Range<Line>, T> for Grid<T> { } impl<T> IndexRegion<RangeTo<Line>, T> for Grid<T> { - fn region(&self, index: RangeTo<Line>) -> Region<T> { + fn region(&self, index: RangeTo<Line>) -> Region<'_, T> { assert!(index.end <= self.num_lines()); Region { start: Line(0), @@ -623,7 +623,7 @@ impl<T> IndexRegion<RangeTo<Line>, T> for Grid<T> { raw: &self.raw } } - fn region_mut(&mut self, index: RangeTo<Line>) -> RegionMut<T> { + fn region_mut(&mut self, index: RangeTo<Line>) -> RegionMut<'_, T> { assert!(index.end <= self.num_lines()); RegionMut { start: Line(0), @@ -634,7 +634,7 @@ impl<T> IndexRegion<RangeTo<Line>, T> for Grid<T> { } impl<T> IndexRegion<RangeFrom<Line>, T> for Grid<T> { - fn region(&self, index: RangeFrom<Line>) -> Region<T> { + fn region(&self, index: RangeFrom<Line>) -> Region<'_, T> { assert!(index.start < self.num_lines()); Region { start: index.start, @@ -642,7 +642,7 @@ impl<T> IndexRegion<RangeFrom<Line>, T> for Grid<T> { raw: &self.raw } } - fn region_mut(&mut self, index: RangeFrom<Line>) -> RegionMut<T> { + fn region_mut(&mut self, index: RangeFrom<Line>) -> RegionMut<'_, T> { assert!(index.start < self.num_lines()); RegionMut { start: index.start, @@ -653,7 +653,7 @@ impl<T> IndexRegion<RangeFrom<Line>, T> for Grid<T> { } impl<T> IndexRegion<RangeFull, T> for Grid<T> { - fn region(&self, _: RangeFull) -> Region<T> { + fn region(&self, _: RangeFull) -> Region<'_, T> { Region { start: Line(0), end: self.num_lines(), @@ -661,7 +661,7 @@ impl<T> IndexRegion<RangeFull, T> for Grid<T> { } } - fn region_mut(&mut self, _: RangeFull) -> RegionMut<T> { + fn region_mut(&mut self, _: RangeFull) -> RegionMut<'_, T> { RegionMut { start: Line(0), end: self.num_lines(), @@ -670,13 +670,13 @@ impl<T> IndexRegion<RangeFull, T> for Grid<T> { } } -pub struct RegionIter<'a, T: 'a> { +pub struct RegionIter<'a, T> { end: Line, cur: Line, raw: &'a Storage<T>, } -pub struct RegionIterMut<'a, T: 'a> { +pub struct RegionIterMut<'a, T> { end: Line, cur: Line, raw: &'a mut Storage<T>, @@ -741,7 +741,7 @@ impl<'a, T> Iterator for RegionIterMut<'a, T> { // ------------------------------------------------------------------------------------------------- /// Iterates over the visible area accounting for buffer transform -pub struct DisplayIter<'a, T: 'a> { +pub struct DisplayIter<'a, T> { grid: &'a Grid<T>, offset: usize, limit: usize, diff --git a/src/grid/row.rs b/src/grid/row.rs index abfb9f93..72c79b02 100644 --- a/src/grid/row.rs +++ b/src/grid/row.rs @@ -19,7 +19,7 @@ use std::ops::{Range, RangeTo, RangeFrom, RangeFull, RangeToInclusive}; use std::cmp::{max, min}; use std::slice; -use index::Column; +use crate::index::Column; /// A row in the grid #[derive(Default, Clone, Debug, Serialize, Deserialize)] @@ -85,7 +85,7 @@ impl<T> Row<T> { self.inner.len() } - pub fn iter(&self) -> slice::Iter<T> { + pub fn iter(&self) -> slice::Iter<'_, T> { self.inner.iter() } } diff --git a/src/grid/storage.rs b/src/grid/storage.rs index 471afdae..19c1636d 100644 --- a/src/grid/storage.rs +++ b/src/grid/storage.rs @@ -14,7 +14,9 @@ use std::ops::{Index, IndexMut}; use std::slice; -use index::Line; +use static_assertions::assert_eq_size; + +use crate::index::Line; use super::Row; /// Maximum number of invisible lines before buffer is resized @@ -277,8 +279,7 @@ impl<T> Index<usize> for Storage<T> { type Output = Row<T>; #[inline] fn index(&self, index: usize) -> &Self::Output { - let index = self.compute_index(index); // borrowck - &self.inner[index] + &self.inner[self.compute_index(index)] } } @@ -308,7 +309,7 @@ impl<T> IndexMut<Line> for Storage<T> { } #[cfg(test)] -use index::Column; +use crate::index::Column; /// Grow the buffer one line at the end of the buffer /// diff --git a/src/grid/tests.rs b/src/grid/tests.rs index 9cb30a7f..2e06c10e 100644 --- a/src/grid/tests.rs +++ b/src/grid/tests.rs @@ -15,7 +15,7 @@ //! Tests for the Gird use super::{Grid, BidirectionalIterator}; -use index::{Point, Line, Column}; +use crate::index::{Point, Line, Column}; // Scroll up moves lines upwards #[test] |