Closed
Description
Please check the code bellow
https://play.rust-lang.org/?gist=c0dd3d93bde346c4bd4d&version=nightly
#![feature(drain)]
use std::sync::{Arc, RwLock};
fn main() {
let files = RwLock::new(vec![Arc::new(1u32)]);
// WONT compile
let a: Vec<_> = files.write().unwrap().drain(..1).collect();
// WONT compile
let a: Vec<_> = {
let mut temp = files.write().unwrap();
temp.drain(..1).collect()
};
// compiles
let a: Vec<_> = {
let mut temp = files.write().unwrap();
let res = temp.drain(..1).collect();
res
};
println!("{:?}", a);
}
I suppose all of them should compile as they do the same thing, but only the last one does.