parent
8eed67a906
commit
62553b334c
@ -1 +1,2 @@
|
||||
/owning_ref-0.3.3.crate
|
||||
/owning_ref-0.4.0.crate
|
||||
|
@ -1,51 +0,0 @@
|
||||
From f629c7b7db163a919cdd6a353c3318b1d66d5fad Mon Sep 17 00:00:00 2001
|
||||
From: Alexandre Bury <alexandre.bury@gmail.com>
|
||||
Date: Wed, 10 Jan 2018 15:29:34 +0100
|
||||
Subject: [PATCH] Fix tests
|
||||
|
||||
Lifetime inference does not work here, we need to define the lifetimes.
|
||||
But we can't do that with closures [1] so we use a function instead.
|
||||
|
||||
[1]: https://github.com/rust-lang/rust/issues/22340
|
||||
---
|
||||
src/lib.rs | 18 ++++++++++++++++--
|
||||
1 file changed, 16 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/lib.rs b/src/lib.rs
|
||||
index 21ed086..31dae97 100644
|
||||
--- a/src/lib.rs
|
||||
+++ b/src/lib.rs
|
||||
@@ -1262,8 +1262,15 @@ mod tests {
|
||||
let foo = [413, 612];
|
||||
let bar = &foo;
|
||||
|
||||
+ // FIXME: lifetime inference fails us, and we can't easily define a lifetime for a closure
|
||||
+ // (see https://github.com/rust-lang/rust/issues/22340)
|
||||
+ // So we use a function to identify the lifetimes instead.
|
||||
+ fn borrow<'a>(a: &'a &[i32; 2]) -> &'a i32 {
|
||||
+ &a[0]
|
||||
+ }
|
||||
+
|
||||
let o: BoxRef<&[i32; 2]> = Box::new(bar).into();
|
||||
- let o: BoxRef<&[i32; 2], i32> = o.map(|a: &&[i32; 2]| &a[0]);
|
||||
+ let o: BoxRef<&[i32; 2], i32> = o.map(borrow);
|
||||
let o: BoxRef<Erased, i32> = o.erase_owner();
|
||||
|
||||
assert_eq!(*o, 413);
|
||||
@@ -1693,8 +1700,15 @@ mod tests {
|
||||
let mut foo = [413, 612];
|
||||
let bar = &mut foo;
|
||||
|
||||
+ // FIXME: lifetime inference fails us, and we can't easily define a lifetime for a closure
|
||||
+ // (see https://github.com/rust-lang/rust/issues/22340)
|
||||
+ // So we use a function to identify the lifetimes instead.
|
||||
+ fn borrow<'a>(a: &'a mut &mut [i32; 2]) -> &'a mut i32 {
|
||||
+ &mut a[0]
|
||||
+ }
|
||||
+
|
||||
let o: BoxRefMut<&mut [i32; 2]> = Box::new(bar).into();
|
||||
- let o: BoxRefMut<&mut [i32; 2], i32> = o.map_mut(|a: &mut &mut [i32; 2]| &mut a[0]);
|
||||
+ let o: BoxRefMut<&mut [i32; 2], i32> = o.map_mut(borrow);
|
||||
let o: BoxRefMut<Erased, i32> = o.erase_owner();
|
||||
|
||||
assert_eq!(*o, 413);
|
@ -1 +1 @@
|
||||
SHA512 (owning_ref-0.3.3.crate) = 260f3d77f23b092c5ca96dff6746d378caa1bac965745a71ca18eed30a12c6869af62259daafc91c8666baf95e04619ad0d8fe06b47d5e517688b35f0c59005a
|
||||
SHA512 (owning_ref-0.4.0.crate) = 51bb1cb259452f7395bce0ac4e7d2d6f3733dfe7a8a1a46d50179516ef921924f745a248e4816da5e434b589b5956a20ca554f9a93790b2ed1c55451b9b885ba
|
||||
|
Loading…
Reference in new issue