aboutsummaryrefslogtreecommitdiff
path: root/src/grid.rs
diff options
context:
space:
mode:
authorJoe Wilm <jwilm@users.noreply.github.com>2017-01-06 21:51:24 -0800
committerGitHub <noreply@github.com>2017-01-06 21:51:24 -0800
commit852c2d8f15bfc11f0222fa08626c38724accd35a (patch)
tree0880b8e38d76ae4ba0fb1772fbd11cae53168729 /src/grid.rs
parent62739bd226974358a811b4680b4b74c268418f5b (diff)
parent4e1f4c8cd7180606156b71ad0222f60e4559f2b3 (diff)
downloadr-alacritty-852c2d8f15bfc11f0222fa08626c38724accd35a.tar.gz
r-alacritty-852c2d8f15bfc11f0222fa08626c38724accd35a.tar.bz2
r-alacritty-852c2d8f15bfc11f0222fa08626c38724accd35a.zip
Merge pull request #131 from Manishearth/stable
Make it compile on stable Rust (almost)
Diffstat (limited to 'src/grid.rs')
-rw-r--r--src/grid.rs13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/grid.rs b/src/grid.rs
index 77fe92b9..5c3da769 100644
--- a/src/grid.rs
+++ b/src/grid.rs
@@ -24,10 +24,9 @@ use std::borrow::ToOwned;
use std::cmp::Ordering;
use std::iter::IntoIterator;
use std::ops::{Deref, DerefMut, Range, RangeTo, RangeFrom, RangeFull, Index, IndexMut};
-use std::ops::RangeInclusive;
use std::slice::{self, Iter, IterMut};
-use index::{self, Point};
+use index::{self, Point, IndexRange, RangeInclusive};
/// Convert a type to a linear index range.
pub trait ToRange {
@@ -53,7 +52,7 @@ pub struct Grid<T> {
impl<T: Clone> Grid<T> {
pub fn new(lines: index::Line, cols: index::Column, template: &T) -> Grid<T> {
let mut raw = Vec::with_capacity(*lines);
- for _ in index::Line(0)..lines {
+ for _ in IndexRange(index::Line(0)..lines) {
raw.push(Row::new(cols, template));
}
@@ -84,7 +83,7 @@ impl<T: Clone> Grid<T> {
}
fn grow_lines(&mut self, lines: index::Line, template: &T) {
- for _ in self.num_lines()..lines {
+ for _ in IndexRange(self.num_lines()..lines) {
self.raw.push(Row::new(self.cols, template));
}
@@ -124,7 +123,7 @@ impl<T> Grid<T> {
#[inline]
pub fn scroll_down(&mut self, region: Range<index::Line>, positions: index::Line) {
- for line in region.rev() {
+ for line in IndexRange(region).rev() {
let src = line;
let dst = line - positions;
self.swap_lines(src, dst);
@@ -133,7 +132,7 @@ impl<T> Grid<T> {
#[inline]
pub fn scroll_up(&mut self, region: Range<index::Line>, positions: index::Line) {
- for line in region {
+ for line in IndexRange(region) {
let src = line;
let dst = line + positions;
self.swap_lines(src, dst);
@@ -151,7 +150,7 @@ impl<T> Grid<T> {
/// better error messages by doing the bounds checking ourselves.
#[inline]
pub fn swap_lines(&mut self, src: index::Line, dst: index::Line) {
- use std::intrinsics::unlikely;
+ use util::unlikely;
unsafe {
// check that src/dst are in bounds. Since index::Line newtypes usize,