aboutsummaryrefslogtreecommitdiff
path: root/src/index.rs
diff options
context:
space:
mode:
authorJoe Wilm <joe@jwilm.com>2016-07-15 07:55:44 -0700
committerJoe Wilm <joe@jwilm.com>2016-07-15 07:55:44 -0700
commit80f6f542abf8701de45010f5f29f4bfae74fe8cd (patch)
tree1067f664278cf5b9a2998bc0e71f6201a8d3c00f /src/index.rs
parent316ccd1c3a883f447d63fd5c935cdf5f37e75157 (diff)
downloadalacritty-80f6f542abf8701de45010f5f29f4bfae74fe8cd.tar.gz
alacritty-80f6f542abf8701de45010f5f29f4bfae74fe8cd.zip
Update to latest nightly
Previous version of serde no longer worked; cargo packages were updated as a result. `Zero` and `One` traits were deprecated. Use of those was removed. The `Step` trait gained a lot more methods, and the index::$ty implementations were updated.
Diffstat (limited to 'src/index.rs')
-rw-r--r--src/index.rs51
1 files changed, 33 insertions, 18 deletions
diff --git a/src/index.rs b/src/index.rs
index a4167e0d..61c39fd6 100644
--- a/src/index.rs
+++ b/src/index.rs
@@ -17,7 +17,7 @@
/// Indexing types and implementations for Grid and Line
use std::fmt;
use std::iter::Step;
-use std::num::{One, Zero};
+use std::mem;
use std::ops::{self, Deref, Add};
/// Index in the grid using row, column notation
@@ -134,31 +134,15 @@ macro_rules! sub {
}
}
-macro_rules! zero_one {
- ($ty:ty, $construct:expr) => {
- impl One for $ty {
- fn one() -> $ty {
- $construct(1)
- }
- }
-
- impl Zero for $ty {
- fn zero() -> $ty {
- $construct(0)
- }
- }
- }
-}
-
macro_rules! ops {
($ty:ty, $construct:expr) => {
add!($ty, $construct);
sub!($ty, $construct);
- zero_one!($ty, $construct);
deref!($ty, usize);
forward_ref_binop!(impl Add, add for $ty, $ty);
impl Step for $ty {
+ #[inline]
fn step(&self, by: &$ty) -> Option<$ty> {
Some(*self + *by)
}
@@ -180,6 +164,37 @@ macro_rules! ops {
Some(0)
}
}
+
+ #[inline]
+ fn steps_between_by_one(start: &$ty, end: &$ty) -> Option<usize> {
+ Step::steps_between(start, end, &$construct(1))
+ }
+
+ #[inline]
+ #[allow(unused_comparisons)]
+ fn is_negative(&self) -> bool {
+ self.0 < 0
+ }
+
+ #[inline]
+ fn replace_one(&mut self) -> Self {
+ mem::replace(self, $construct(0))
+ }
+
+ #[inline]
+ fn replace_zero(&mut self) -> Self {
+ mem::replace(self, $construct(1))
+ }
+
+ #[inline]
+ fn add_one(&self) -> Self {
+ *self + 1
+ }
+
+ #[inline]
+ fn sub_one(&self) -> Self {
+ *self - 1
+ }
}
impl ops::AddAssign<$ty> for $ty {