]> git.lizzy.rs Git - rust.git/blobdiff - src/vector_clock.rs
make miri a better RUSTC by default inside cargo-miri
[rust.git] / src / vector_clock.rs
index a2e235858d83abf13f4cf8bc7f37ad9e923d4f16..716fdba0f67c29aee28d5448eba1c55a46660956 100644 (file)
@@ -1,6 +1,6 @@
 use rustc_index::vec::Idx;
 use smallvec::SmallVec;
-use std::{cmp::Ordering, convert::TryFrom, fmt::Debug, ops::Index};
+use std::{cmp::Ordering, fmt::Debug, ops::Index};
 
 /// A vector clock index, this is associated with a thread id
 /// but in some cases one vector index may be shared with
@@ -108,10 +108,8 @@ pub fn join(&mut self, other: &Self) {
 
     /// Set the element at the current index of the vector
     pub fn set_at_index(&mut self, other: &Self, idx: VectorIdx) {
-        let idx = idx.index();
-        let mut_slice = self.get_mut_with_min_len(idx + 1);
-        let slice = other.as_slice();
-        mut_slice[idx] = slice[idx];
+        let mut_slice = self.get_mut_with_min_len(idx.index() + 1);
+        mut_slice[idx.index()] = other[idx];
     }
 
     /// Set the vector to the all-zero vector
@@ -186,16 +184,18 @@ fn partial_cmp(&self, other: &VClock) -> Option<Ordering> {
             Ordering::Equal => Some(order),
             // Right has at least 1 element > than the implicit 0,
             // so the only valid values are Ordering::Less or None.
-            Ordering::Less => match order {
-                Ordering::Less | Ordering::Equal => Some(Ordering::Less),
-                Ordering::Greater => None,
-            },
+            Ordering::Less =>
+                match order {
+                    Ordering::Less | Ordering::Equal => Some(Ordering::Less),
+                    Ordering::Greater => None,
+                },
             // Left has at least 1 element > than the implicit 0,
             // so the only valid values are Ordering::Greater or None.
-            Ordering::Greater => match order {
-                Ordering::Greater | Ordering::Equal => Some(Ordering::Greater),
-                Ordering::Less => None,
-            },
+            Ordering::Greater =>
+                match order {
+                    Ordering::Greater | Ordering::Equal => Some(Ordering::Greater),
+                    Ordering::Less => None,
+                },
         }
     }