fork/rust
git clone https://git.julia.blue/fork/rust
3bcad65fbf6
master
1// run-rustfix 2#![allow(unused_mut)] 3#![allow(dead_code)] 4use std::path::PathBuf; 5 6#[derive(Clone)] 7struct Container { 8 things: Vec<PathBuf>, 9} 10 11impl Container { 12 fn things(&mut self) -> &[PathBuf] { 13 &self.things 14 } 15} 16 17// contains containers 18struct ContainerContainer { 19 contained: Vec<Container>, 20} 21 22impl ContainerContainer { 23 fn contained(&self) -> &[Container] { 24 &self.contained 25 } 26 27 fn all_the_things(&mut self) -> &[PathBuf] { 28 let mut vec = self.contained.clone(); 29 let _a = 30 vec.iter_mut().flat_map(|container| container.things()).cloned().collect::<Vec<PathBuf>>(); 31 //~^ ERROR cannot borrow `*container` as mutable, as it is behind a `&` reference 32 unimplemented!(); 33 } 34} 35 36fn main() {}