diff options
author | Christian Duerr <chrisduerr@users.noreply.github.com> | 2019-03-30 16:48:36 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-30 16:48:36 +0000 |
commit | cfd025b5289bc305470a96657868c982a2b13bc2 (patch) | |
tree | 093b9105c881e28b909e031c46d2054016b643b3 /src/index.rs | |
parent | 91aa683bcd060b2ac2f621a388a6448f564d0537 (diff) | |
download | alacritty-cfd025b5289bc305470a96657868c982a2b13bc2.tar.gz alacritty-cfd025b5289bc305470a96657868c982a2b13bc2.zip |
Add rustfmt style guidev0.3.0-rc1
Diffstat (limited to 'src/index.rs')
-rw-r--r-- | src/index.rs | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/src/index.rs b/src/index.rs index 0004454e..0351c0ee 100644 --- a/src/index.rs +++ b/src/index.rs @@ -17,18 +17,18 @@ /// Indexing types and implementations for Grid and Line use std::cmp::{Ord, Ordering}; use std::fmt; -use std::ops::{self, Deref, Range, RangeInclusive, Add, Sub, AddAssign, SubAssign}; +use std::ops::{self, Add, AddAssign, Deref, Range, RangeInclusive, Sub, SubAssign}; /// The side of a cell #[derive(Debug, Copy, Clone, Eq, PartialEq)] pub enum Side { Left, - Right + Right, } /// Index in the grid using row, column notation #[derive(Debug, Clone, Copy, Default, Eq, PartialEq, Serialize, Deserialize, PartialOrd)] -pub struct Point<L=Line> { +pub struct Point<L = Line> { pub line: L, pub col: Column, } @@ -43,11 +43,10 @@ impl Ord for Point { fn cmp(&self, other: &Point) -> Ordering { use std::cmp::Ordering::*; match (self.line.cmp(&other.line), self.col.cmp(&other.col)) { - (Equal, Equal) => Equal, - (Equal, ord) | - (ord, Equal) => ord, - (Less, _) => Less, - (Greater, _) => Greater, + (Equal, Equal) => Equal, + (Equal, ord) | (ord, Equal) => ord, + (Less, _) => Less, + (Greater, _) => Greater, } } } @@ -156,7 +155,7 @@ macro_rules! forward_ref_binop { $imp::$method(*self, *other) } } - } + }; } /// Macro for deriving deref @@ -170,7 +169,7 @@ macro_rules! deref { &self.0 } } - } + }; } macro_rules! add { @@ -183,7 +182,7 @@ macro_rules! add { $construct(self.0 + rhs.0) } } - } + }; } macro_rules! sub { @@ -223,7 +222,7 @@ macro_rules! sub { $construct(self.0 - rhs.0) } } - } + }; } /// This exists because we can't implement Iterator on Range @@ -246,6 +245,7 @@ pub trait Contains { impl<T: PartialOrd<T>> Contains for Range<T> { type Content = T; + fn contains_(&self, item: Self::Content) -> bool { (self.start <= item) && (item < self.end) } @@ -253,6 +253,7 @@ impl<T: PartialOrd<T>> Contains for Range<T> { impl<T: PartialOrd<T>> Contains for RangeInclusive<T> { type Content = T; + fn contains_(&self, item: Self::Content) -> bool { (self.start() <= &item) && (&item <= self.end()) } @@ -383,7 +384,7 @@ ops!(Linear, Linear); #[cfg(test)] mod tests { - use super::{Line, Column, Point}; + use super::{Column, Line, Point}; #[test] fn location_ordering() { |