Răsfoiți Sursa

add test: check_numassignref_ops

Sergei Shilovsky 4 ani în urmă
părinte
comite
42e3f95797
1 a modificat fișierele cu 12 adăugiri și 2 ștergeri
  1. 12 2
      src/lib.rs

+ 12 - 2
src/lib.rs

@@ -622,5 +622,15 @@ fn check_numassign_ops() {
     assert_eq!(compute(1, 2), 1)
 }
 
-// TODO test `NumAssignRef`, but even the standard numeric types don't
-// implement this yet. (see rust pr41336)
+#[test]
+fn check_numassignref_ops() {
+    fn compute<T: NumAssignRef + Copy>(mut x: T, y: &T) -> T {
+        x *= y;
+        x /= y;
+        x %= y;
+        x += y;
+        x -= y;
+        x
+    }
+    assert_eq!(compute(1, &2), 1)
+}