浏览代码

add test: check_numassignref_ops

Sergei Shilovsky 4 年之前
父节点
当前提交
42e3f95797
共有 1 个文件被更改,包括 12 次插入2 次删除
  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)
+}