From 217ad9ec285b4923de1790b0976c8c793039c994 Mon Sep 17 00:00:00 2001 From: Joe Wilm Date: Mon, 10 Dec 2018 09:53:56 -0800 Subject: Upgrade to Rust 2018 This resolves a lot of NLL issues, however full NLL will be necessary to handle a couple of remaining issues. --- src/grid/mod.rs | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'src/grid/mod.rs') 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 { max_scroll_limit: usize, } -pub struct GridIterator<'a, T: 'a> { +pub struct GridIterator<'a, T> { /// Immutable grid reference grid: &'a Grid, @@ -411,7 +411,7 @@ impl Grid { self.lines } - pub fn display_iter(&self) -> DisplayIter { + pub fn display_iter(&self) -> DisplayIter<'_, T> { DisplayIter::new(self) } @@ -454,7 +454,7 @@ impl Grid { self.raw.truncate(); } - pub fn iter_from(&self, point: Point) -> GridIterator { + pub fn iter_from(&self, point: Point) -> GridIterator<'_, T> { GridIterator { grid: self, cur: point, @@ -557,7 +557,7 @@ impl<'point, T> IndexMut<&'point Point> for Grid { /// 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, @@ -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, @@ -585,14 +585,14 @@ impl<'a, T> RegionMut<'a, T> { pub trait IndexRegion { /// Get an immutable region of Self - fn region(&self, _: I) -> Region; + fn region(&self, _: I) -> Region<'_, T>; /// Get a mutable region of Self - fn region_mut(&mut self, _: I) -> RegionMut; + fn region_mut(&mut self, _: I) -> RegionMut<'_, T>; } impl IndexRegion, T> for Grid { - fn region(&self, index: Range) -> Region { + fn region(&self, index: Range) -> Region<'_, T> { assert!(index.start < self.num_lines()); assert!(index.end <= self.num_lines()); assert!(index.start <= index.end); @@ -602,7 +602,7 @@ impl IndexRegion, T> for Grid { raw: &self.raw } } - fn region_mut(&mut self, index: Range) -> RegionMut { + fn region_mut(&mut self, index: Range) -> RegionMut<'_, T> { assert!(index.start < self.num_lines()); assert!(index.end <= self.num_lines()); assert!(index.start <= index.end); @@ -615,7 +615,7 @@ impl IndexRegion, T> for Grid { } impl IndexRegion, T> for Grid { - fn region(&self, index: RangeTo) -> Region { + fn region(&self, index: RangeTo) -> Region<'_, T> { assert!(index.end <= self.num_lines()); Region { start: Line(0), @@ -623,7 +623,7 @@ impl IndexRegion, T> for Grid { raw: &self.raw } } - fn region_mut(&mut self, index: RangeTo) -> RegionMut { + fn region_mut(&mut self, index: RangeTo) -> RegionMut<'_, T> { assert!(index.end <= self.num_lines()); RegionMut { start: Line(0), @@ -634,7 +634,7 @@ impl IndexRegion, T> for Grid { } impl IndexRegion, T> for Grid { - fn region(&self, index: RangeFrom) -> Region { + fn region(&self, index: RangeFrom) -> Region<'_, T> { assert!(index.start < self.num_lines()); Region { start: index.start, @@ -642,7 +642,7 @@ impl IndexRegion, T> for Grid { raw: &self.raw } } - fn region_mut(&mut self, index: RangeFrom) -> RegionMut { + fn region_mut(&mut self, index: RangeFrom) -> RegionMut<'_, T> { assert!(index.start < self.num_lines()); RegionMut { start: index.start, @@ -653,7 +653,7 @@ impl IndexRegion, T> for Grid { } impl IndexRegion for Grid { - fn region(&self, _: RangeFull) -> Region { + fn region(&self, _: RangeFull) -> Region<'_, T> { Region { start: Line(0), end: self.num_lines(), @@ -661,7 +661,7 @@ impl IndexRegion for Grid { } } - fn region_mut(&mut self, _: RangeFull) -> RegionMut { + fn region_mut(&mut self, _: RangeFull) -> RegionMut<'_, T> { RegionMut { start: Line(0), end: self.num_lines(), @@ -670,13 +670,13 @@ impl IndexRegion for Grid { } } -pub struct RegionIter<'a, T: 'a> { +pub struct RegionIter<'a, T> { end: Line, cur: Line, raw: &'a Storage, } -pub struct RegionIterMut<'a, T: 'a> { +pub struct RegionIterMut<'a, T> { end: Line, cur: Line, raw: &'a mut Storage, @@ -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, offset: usize, limit: usize, -- cgit