diff --git a/components/gfx/text/glyph.rs b/components/gfx/text/glyph.rs index 06e16c04a79..312c0692847 100644 --- a/components/gfx/text/glyph.rs +++ b/components/gfx/text/glyph.rs @@ -7,7 +7,7 @@ use servo_util::range; use servo_util::range::{Range, RangeIndex, EachIndex}; use servo_util::geometry::Au; -use std::cmp::PartialOrd; +use std::cmp::{Ordering, PartialOrd}; use std::iter::repeat; use std::num::NumCast; use std::mem; @@ -398,9 +398,9 @@ impl<'a> DetailedGlyphStore { let mut mut_records : Vec = unsorted_records; mut_records.sort_by(|a, b| { if a < b { - Less + Ordering::Less } else { - Greater + Ordering::Greater } }); let mut sorted_records = mut_records; diff --git a/components/gfx/text/text_run.rs b/components/gfx/text/text_run.rs index 8b8230a94cc..da5b6f3435e 100644 --- a/components/gfx/text/text_run.rs +++ b/components/gfx/text/text_run.rs @@ -8,6 +8,7 @@ use platform::font_template::FontTemplateData; use servo_util::geometry::Au; use servo_util::range::Range; use servo_util::vec::{Comparator, FullBinarySearchMethods}; +use std::cmp::Ordering; use std::slice::Items; use std::sync::Arc; use text::glyph::{CharIndex, GlyphStore}; @@ -42,11 +43,11 @@ struct CharIndexComparator; impl Comparator for CharIndexComparator { fn compare(&self, key: &CharIndex, value: &GlyphRun) -> Ordering { if *key < value.range.begin() { - Less + Ordering::Less } else if *key >= value.range.end() { - Greater + Ordering::Greater } else { - Equal + Ordering::Equal } } } diff --git a/components/style/selector_matching.rs b/components/style/selector_matching.rs index dba0294baec..c617b58e7f2 100644 --- a/components/style/selector_matching.rs +++ b/components/style/selector_matching.rs @@ -1161,6 +1161,7 @@ impl FindPush for HashMap> { #[cfg(test)] mod tests { + use std::cmp::Ordering; use std::sync::Arc; use super::{DeclarationBlock, Rule, SelectorMap}; use selectors::LocalName; @@ -1201,7 +1202,7 @@ mod tests { let rules_list = get_mock_rules(&["a.intro", "img.sidebar"]); let a = &rules_list[0][0].declarations; let b = &rules_list[1][0].declarations; - assert!((a.specificity, a.source_order).cmp(&(b.specificity, b.source_order)) == Less, + assert!((a.specificity, a.source_order).cmp(&(b.specificity, b.source_order)) == Ordering::Less, "The rule that comes later should win."); } diff --git a/components/util/sort.rs b/components/util/sort.rs index 73a244f713f..d31948cb0e8 100644 --- a/components/util/sort.rs +++ b/components/util/sort.rs @@ -4,6 +4,8 @@ //! In-place sorting. +use std::cmp::Ordering; + fn quicksort_helper(arr: &mut [T], left: int, right: int, compare: fn(&T, &T) -> Ordering) { if right <= left { return @@ -17,11 +19,11 @@ fn quicksort_helper(arr: &mut [T], left: int, right: int, compare: fn(&T, &T) let v: *mut T = &mut arr[right as uint]; loop { i += 1; - while compare(&arr[i as uint], &*v) == Less { + while compare(&arr[i as uint], &*v) == Ordering::Less { i += 1 } j -= 1; - while compare(&*v, &arr[j as uint]) == Less { + while compare(&*v, &arr[j as uint]) == Ordering::Less { if j == left { break } @@ -31,11 +33,11 @@ fn quicksort_helper(arr: &mut [T], left: int, right: int, compare: fn(&T, &T) break } arr.swap(i as uint, j as uint); - if compare(&arr[i as uint], &*v) == Equal { + if compare(&arr[i as uint], &*v) == Ordering::Equal { p += 1; arr.swap(p as uint, i as uint) } - if compare(&*v, &arr[j as uint]) == Equal { + if compare(&*v, &arr[j as uint]) == Ordering::Equal { q -= 1; arr.swap(j as uint, q as uint) } diff --git a/components/util/time.rs b/components/util/time.rs index abe35633e92..a47f3a98c8c 100644 --- a/components/util/time.rs +++ b/components/util/time.rs @@ -6,6 +6,7 @@ use collections::TreeMap; use std::borrow::ToOwned; +use std::cmp::Ordering; use std::comm::{Sender, channel, Receiver}; use std::f64; use std::io::timer::sleep; @@ -228,9 +229,9 @@ impl TimeProfiler { for (&(ref category, ref meta), ref mut data) in self.buckets.iter_mut() { data.sort_by(|a, b| { if a < b { - Less + Ordering::Less } else { - Greater + Ordering::Greater } }); let data_len = data.len(); diff --git a/components/util/vec.rs b/components/util/vec.rs index b9a67b6760b..c34b76a9794 100644 --- a/components/util/vec.rs +++ b/components/util/vec.rs @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -use std::cmp::{PartialOrd, PartialEq}; +use std::cmp::{PartialOrd, PartialEq, Ordering}; #[cfg(test)] use std::fmt::Show; @@ -47,9 +47,9 @@ impl<'a, T> FullBinarySearchMethods for &'a [T] { let midv = &self[mid]; match cmp.compare(key, midv) { - Greater => low = (mid as int) + 1, - Less => high = (mid as int) - 1, - Equal => return Some(mid), + Ordering::Greater => low = (mid as int) + 1, + Ordering::Less => high = (mid as int) - 1, + Ordering::Equal => return Some(mid), } } return None; diff --git a/ports/cef/string.rs b/ports/cef/string.rs index d0a0e4ba4e3..a396eabff69 100644 --- a/ports/cef/string.rs +++ b/ports/cef/string.rs @@ -7,6 +7,7 @@ use eutil::slice_to_str; use libc::{mod, size_t, c_int, c_ushort, c_void}; use libc::types::os::arch::c95::wchar_t; use std::char; +use std::cmp::Ordering; use std::mem; use std::ptr; use std::slice; @@ -106,15 +107,15 @@ pub extern "C" fn cef_string_utf8_set(src: *const u8, src_len: size_t, output: * #[no_mangle] pub extern "C" fn cef_string_utf8_cmp(a: *const cef_string_utf8_t, b: *const cef_string_utf8_t) -> c_int { unsafe { - slice::raw::buf_as_slice((*a).str as *const u8, (*a).length as uint, |astr:&[u8]| { + slice::raw::buf_as_slice((*a).str as *const u8, (*a).length as uint, |astr:&[u8]| { slice::raw::buf_as_slice((*b).str as *const u8, (*b).length as uint, |bstr:&[u8]| { - match astr.cmp(bstr) { - Less => -1, - Equal => 0, - Greater => 1 - } + match astr.cmp(bstr) { + Ordering::Less => -1, + Ordering::Equal => 0, + Ordering::Greater => 1 + } }) - }) + }) } } @@ -188,15 +189,15 @@ pub extern "C" fn cef_string_utf16_set(src: *const c_ushort, src_len: size_t, ou #[no_mangle] pub extern "C" fn cef_string_utf16_cmp(a: *const cef_string_utf16_t, b: *const cef_string_utf16_t) -> c_int { unsafe { - slice::raw::buf_as_slice(mem::transmute((*a).str), (*a).length as uint, |astr:&[u16]| { + slice::raw::buf_as_slice(mem::transmute((*a).str), (*a).length as uint, |astr:&[u16]| { slice::raw::buf_as_slice(mem::transmute((*b).str), (*b).length as uint, |bstr:&[u16]| { - match astr.cmp(bstr) { - Less => -1, - Equal => 0, - Greater => 1 - } + match astr.cmp(bstr) { + Ordering::Less => -1, + Ordering::Equal => 0, + Ordering::Greater => 1 + } }) - }) + }) } } @@ -246,15 +247,15 @@ pub extern "C" fn cef_string_wide_set(src: *const wchar_t, src_len: size_t, outp #[no_mangle] pub extern "C" fn cef_string_wide_cmp(a: *const cef_string_wide_t, b: *const cef_string_wide_t) -> c_int { unsafe { - slice::raw::buf_as_slice((*a).str as *const wchar_t, (*a).length as uint, |astr:&[wchar_t]| { + slice::raw::buf_as_slice((*a).str as *const wchar_t, (*a).length as uint, |astr:&[wchar_t]| { slice::raw::buf_as_slice((*b).str as *const wchar_t, (*b).length as uint, |bstr:&[wchar_t]| { - match astr.cmp(bstr) { - Less => -1, - Equal => 0, - Greater => 1 - } + match astr.cmp(bstr) { + Ordering::Less => -1, + Ordering::Equal => 0, + Ordering::Greater => 1 + } }) - }) + }) } }