aboutsummaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2018-09-12 08:14:58 -0400
committerGitHub <noreply@github.com>2018-09-12 08:14:58 -0400
commit16e6bdce6e64f54245ee239ff1eda2eb6536154c (patch)
tree1519be5255ba9d58212df8a484c6561be0872203 /components
parent4c4c2515a244474bc1f6fd95646ba4c5799cde7d (diff)
parent3dc2d31f8897f9457f4e8462b99dca9387f87fe3 (diff)
downloadservo-16e6bdce6e64f54245ee239ff1eda2eb6536154c.tar.gz
servo-16e6bdce6e64f54245ee239ff1eda2eb6536154c.zip
Auto merge of #21685 - AnshulMalik:format-range, r=jdm
format components/range using rustfmt - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/21685) <!-- Reviewable:end -->
Diffstat (limited to 'components')
-rw-r--r--components/range/lib.rs84
1 files changed, 60 insertions, 24 deletions
diff --git a/components/range/lib.rs b/components/range/lib.rs
index 6088d006989..9d65a229717 100644
--- a/components/range/lib.rs
+++ b/components/range/lib.rs
@@ -5,19 +5,18 @@
#![deny(unsafe_code)]
extern crate malloc_size_of;
-#[macro_use] extern crate malloc_size_of_derive;
+#[macro_use]
+extern crate malloc_size_of_derive;
extern crate num_traits;
-#[macro_use] extern crate serde;
+#[macro_use]
+extern crate serde;
use std::cmp::{self, max, min};
use std::fmt;
use std::ops;
pub trait Int:
- Copy
- + ops::Add<Self, Output=Self>
- + ops::Sub<Self, Output=Self>
- + cmp::Ord
+ Copy + ops::Add<Self, Output = Self> + ops::Sub<Self, Output = Self> + cmp::Ord
{
fn zero() -> Self;
fn one() -> Self;
@@ -27,27 +26,47 @@ pub trait Int:
}
impl Int for isize {
#[inline]
- fn zero() -> isize { 0 }
+ fn zero() -> isize {
+ 0
+ }
#[inline]
- fn one() -> isize { 1 }
+ fn one() -> isize {
+ 1
+ }
#[inline]
- fn max_value() -> isize { ::std::isize::MAX }
+ fn max_value() -> isize {
+ ::std::isize::MAX
+ }
#[inline]
- fn from_usize(n: usize) -> Option<isize> { num_traits::NumCast::from(n) }
+ fn from_usize(n: usize) -> Option<isize> {
+ num_traits::NumCast::from(n)
+ }
#[inline]
- fn to_usize(self) -> usize { num_traits::NumCast::from(self).unwrap() }
+ fn to_usize(self) -> usize {
+ num_traits::NumCast::from(self).unwrap()
+ }
}
impl Int for usize {
#[inline]
- fn zero() -> usize { 0 }
+ fn zero() -> usize {
+ 0
+ }
#[inline]
- fn one() -> usize { 1 }
+ fn one() -> usize {
+ 1
+ }
#[inline]
- fn max_value() -> usize { ::std::usize::MAX }
+ fn max_value() -> usize {
+ ::std::usize::MAX
+ }
#[inline]
- fn from_usize(n: usize) -> Option<usize> { Some(n) }
+ fn from_usize(n: usize) -> Option<usize> {
+ Some(n)
+ }
#[inline]
- fn to_usize(self) -> usize { self }
+ fn to_usize(self) -> usize {
+ self
+ }
}
/// An index type to be used by a `Range`
@@ -60,19 +79,27 @@ pub trait RangeIndex: Int + fmt::Debug {
impl RangeIndex for isize {
type Index = isize;
#[inline]
- fn new(x: isize) -> isize { x }
+ fn new(x: isize) -> isize {
+ x
+ }
#[inline]
- fn get(self) -> isize { self }
+ fn get(self) -> isize {
+ self
+ }
}
impl RangeIndex for usize {
type Index = usize;
#[inline]
- fn new(x: usize) -> usize { x }
+ fn new(x: usize) -> usize {
+ x
+ }
#[inline]
- fn get(self) -> usize { self }
+ fn get(self) -> usize {
+ self
+ }
}
/// Implements a range index type with operator overloads
@@ -204,7 +231,10 @@ impl<I: RangeIndex> Range<I> {
/// ~~~
#[inline]
pub fn new(begin: I, length: I) -> Range<I> {
- Range { begin: begin, length: length }
+ Range {
+ begin: begin,
+ length: length,
+ }
}
#[inline]
@@ -220,7 +250,9 @@ impl<I: RangeIndex> Range<I> {
/// <- o - - - - - +============+ - - - ->
/// ~~~
#[inline]
- pub fn begin(&self) -> I { self.begin }
+ pub fn begin(&self) -> I {
+ self.begin
+ }
/// The index offset from the beginning to the end of the range.
///
@@ -230,7 +262,9 @@ impl<I: RangeIndex> Range<I> {
/// <- o - - - - - +============+ - - - ->
/// ~~~
#[inline]
- pub fn length(&self) -> I { self.length }
+ pub fn length(&self) -> I {
+ self.length
+ }
/// The index offset to the end of the range.
///
@@ -240,7 +274,9 @@ impl<I: RangeIndex> Range<I> {
/// <- o - - - - - +============+ - - - ->
/// ~~~
#[inline]
- pub fn end(&self) -> I { self.begin + self.length }
+ pub fn end(&self) -> I {
+ self.begin + self.length
+ }
/// `true` if the index is between the beginning and the end of the range.
///