Fix existing syntactics nits.

This commit is contained in:
Josh Matthews 2015-08-13 19:06:47 -04:00
parent 7f935f010b
commit 8bb853f643
93 changed files with 393 additions and 397 deletions

View file

@ -16,11 +16,11 @@ pub struct HashCache<K, V> {
entries: HashMap<K, V, DefaultState<SipHasher>>,
}
impl<K, V> HashCache<K,V>
impl<K, V> HashCache<K, V>
where K: Clone + PartialEq + Eq + Hash,
V: Clone,
{
pub fn new() -> HashCache<K,V> {
pub fn new() -> HashCache<K, V> {
HashCache {
entries: HashMap::with_hash_state(<DefaultState<SipHasher> as Default>::default()),
}
@ -58,7 +58,7 @@ pub struct LRUCache<K, V> {
cache_size: usize,
}
impl<K: Clone + PartialEq, V: Clone> LRUCache<K,V> {
impl<K: Clone + PartialEq, V: Clone> LRUCache<K, V> {
pub fn new(size: usize) -> LRUCache<K, V> {
LRUCache {
entries: vec!(),
@ -76,7 +76,7 @@ impl<K: Clone + PartialEq, V: Clone> LRUCache<K,V> {
self.entries[last_index].1.clone()
}
pub fn iter<'a>(&'a self) -> Iter<'a,(K,V)> {
pub fn iter<'a>(&'a self) -> Iter<'a,(K, V)> {
self.entries.iter()
}
@ -110,14 +110,14 @@ impl<K: Clone + PartialEq, V: Clone> LRUCache<K,V> {
}
}
pub struct SimpleHashCache<K,V> {
entries: Vec<Option<(K,V)>>,
pub struct SimpleHashCache<K, V> {
entries: Vec<Option<(K, V)>>,
k0: u64,
k1: u64,
}
impl<K:Clone+Eq+Hash,V:Clone> SimpleHashCache<K,V> {
pub fn new(cache_size: usize) -> SimpleHashCache<K,V> {
impl<K: Clone + Eq + Hash, V: Clone> SimpleHashCache<K, V> {
pub fn new(cache_size: usize) -> SimpleHashCache<K, V> {
let mut r = rand::thread_rng();
SimpleHashCache {
entries: vec![None; cache_size],
@ -132,7 +132,7 @@ impl<K:Clone+Eq+Hash,V:Clone> SimpleHashCache<K,V> {
}
#[inline]
fn bucket_for_key<Q:Hash>(&self, key: &Q) -> usize {
fn bucket_for_key<Q: Hash>(&self, key: &Q) -> usize {
let mut hasher = SipHasher::new_with_keys(self.k0, self.k1);
key.hash(&mut hasher);
self.to_bucket(hasher.finish() as usize)

View file

@ -279,7 +279,7 @@ pub fn px_to_pt(px: f64) -> f64 {
/// Returns true if the rect contains the given point. Points on the top or left sides of the rect
/// are considered inside the rectangle, while points on the right or bottom sides of the rect are
/// not considered inside the rectangle.
pub fn rect_contains_point<T:PartialOrd + Add<T, Output=T>>(rect: Rect<T>, point: Point2D<T>) -> bool {
pub fn rect_contains_point<T: PartialOrd + Add<T, Output=T>>(rect: Rect<T>, point: Point2D<T>) -> bool {
point.x >= rect.origin.x && point.x < rect.origin.x + rect.size.width &&
point.y >= rect.origin.y && point.y < rect.origin.y + rect.size.height
}

View file

@ -14,7 +14,7 @@ use std::sync::atomic::{ATOMIC_USIZE_INIT, AtomicUsize, Ordering};
use std::sync::mpsc::{self, Receiver, Sender};
lazy_static! {
static ref IN_PROCESS_SENDERS: Mutex<HashMap<usize,Box<Any + Send>>> =
static ref IN_PROCESS_SENDERS: Mutex<HashMap<usize, Box<Any + Send>>> =
Mutex::new(HashMap::new());
}
@ -49,7 +49,7 @@ impl<T> Clone for OptionalIpcSender<T> where T: Deserialize + Serialize + Send +
impl<T> Deserialize for OptionalIpcSender<T> where T: Deserialize + Serialize + Send + Any {
fn deserialize<D>(deserializer: &mut D)
-> Result<OptionalIpcSender<T>,D::Error> where D: Deserializer {
-> Result<OptionalIpcSender<T>, D::Error> where D: Deserializer {
if opts::get().multiprocess {
return Ok(OptionalIpcSender::OutOfProcess(try!(Deserialize::deserialize(
deserializer))))
@ -66,7 +66,7 @@ impl<T> Deserialize for OptionalIpcSender<T> where T: Deserialize + Serialize +
}
impl<T> Serialize for OptionalIpcSender<T> where T: Deserialize + Serialize + Send + Any {
fn serialize<S>(&self, serializer: &mut S) -> Result<(),S::Error> where S: Serializer {
fn serialize<S>(&self, serializer: &mut S) -> Result<(), S::Error> where S: Serializer {
match *self {
OptionalIpcSender::OutOfProcess(ref ipc_sender) => ipc_sender.serialize(serializer),
OptionalIpcSender::InProcess(ref sender) => {

View file

@ -456,7 +456,7 @@ impl<T: Copy + Add<T, Output=T>> LogicalPoint<T> {
}
}
impl<T: Copy + Add<T,Output=T>> Add<LogicalSize<T>> for LogicalPoint<T> {
impl<T: Copy + Add<T, Output=T>> Add<LogicalSize<T>> for LogicalPoint<T> {
type Output = LogicalPoint<T>;
#[inline]
@ -470,7 +470,7 @@ impl<T: Copy + Add<T,Output=T>> Add<LogicalSize<T>> for LogicalPoint<T> {
}
}
impl<T: Copy + Sub<T,Output=T>> Sub<LogicalSize<T>> for LogicalPoint<T> {
impl<T: Copy + Sub<T, Output=T>> Sub<LogicalSize<T>> for LogicalPoint<T> {
type Output = LogicalPoint<T>;
#[inline]

View file

@ -50,7 +50,7 @@ impl<T> PersistentList<T> where T: Send + Sync {
}
#[inline]
pub fn iter<'a>(&'a self) -> PersistentListIterator<'a,T> {
pub fn iter<'a>(&'a self) -> PersistentListIterator<'a, T> {
// This could clone (and would not need the lifetime if it did), but then it would incur
// atomic operations on every call to `.next()`. Bad.
PersistentListIterator {
@ -74,7 +74,7 @@ pub struct PersistentListIterator<'a,T> where T: 'a + Send + Sync {
entry: Option<&'a PersistentListEntry<T>>,
}
impl<'a,T> Iterator for PersistentListIterator<'a,T> where T: Send + Sync + 'static {
impl<'a, T> Iterator for PersistentListIterator<'a, T> where T: Send + Sync + 'static {
type Item = &'a T;
#[inline]

View file

@ -34,7 +34,7 @@ impl TaskPool {
for i in 0..tasks {
let state = state.clone();
spawn_named(
format!("TaskPoolWorker {}/{}", i+1, tasks),
format!("TaskPoolWorker {}/{}", i + 1, tasks),
move || worker(&*state));
}

View file

@ -10,7 +10,7 @@ use std::ops;
/// FIXME(pcwalton): Workaround for lack of unboxed closures. This is called in
/// performance-critical code, so a closure is insufficient.
pub trait Comparator<K,T> {
pub trait Comparator<K, T> {
fn compare(&self, key: &K, value: &T) -> Ordering;
}
@ -20,7 +20,7 @@ pub trait BinarySearchMethods<T: Ord + PartialOrd + PartialEq> {
}
pub trait FullBinarySearchMethods<T> {
fn binary_search_index_by<K,C:Comparator<K,T>>(&self, key: &K, cmp: C) -> Option<usize>;
fn binary_search_index_by<K, C: Comparator<K, T>>(&self, key: &K, cmp: C) -> Option<usize>;
}
impl<T: Ord + PartialOrd + PartialEq> BinarySearchMethods<T> for [T] {
@ -34,7 +34,7 @@ impl<T: Ord + PartialOrd + PartialEq> BinarySearchMethods<T> for [T] {
}
impl<T> FullBinarySearchMethods<T> for [T] {
fn binary_search_index_by<K,C:Comparator<K,T>>(&self, key: &K, cmp: C) -> Option<usize> {
fn binary_search_index_by<K, C: Comparator<K, T>>(&self, key: &K, cmp: C) -> Option<usize> {
if self.is_empty() {
return None;
}
@ -59,7 +59,7 @@ impl<T> FullBinarySearchMethods<T> for [T] {
struct DefaultComparator;
impl<T:PartialEq + PartialOrd + Ord> Comparator<T,T> for DefaultComparator {
impl<T: PartialEq + PartialOrd + Ord> Comparator<T, T> for DefaultComparator {
fn compare(&self, key: &T, value: &T) -> Ordering {
(*key).cmp(value)
}

View file

@ -273,7 +273,7 @@ impl<QueueData: Sync, WorkData: Send> WorkQueue<QueueData, WorkData> {
for (i, thread) in threads.into_iter().enumerate() {
spawn_named(
format!("{} worker {}/{}", task_name, i+1, thread_count),
format!("{} worker {}/{}", task_name, i + 1, thread_count),
move || {
task_state::initialize(state | task_state::IN_WORKER);
let mut thread = thread;