2024-02-16 14:02:50 -06:00
|
|
|
//@ run-rustfix
|
2023-08-28 03:57:29 -05:00
|
|
|
#![allow(unused_mut)]
|
|
|
|
#![allow(dead_code)]
|
|
|
|
use std::path::PathBuf;
|
|
|
|
|
|
|
|
#[derive(Clone)]
|
|
|
|
struct Container {
|
|
|
|
things: Vec<PathBuf>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Container {
|
|
|
|
fn things(&mut self) -> &[PathBuf] {
|
|
|
|
&self.things
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// contains containers
|
|
|
|
struct ContainerContainer {
|
|
|
|
contained: Vec<Container>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl ContainerContainer {
|
|
|
|
fn contained(&self) -> &[Container] {
|
|
|
|
&self.contained
|
|
|
|
}
|
|
|
|
|
|
|
|
fn all_the_things(&mut self) -> &[PathBuf] {
|
|
|
|
let mut vec = self.contained.clone();
|
|
|
|
let _a =
|
|
|
|
vec.iter_mut().flat_map(|container| container.things()).cloned().collect::<Vec<PathBuf>>();
|
|
|
|
//~^ ERROR cannot borrow `*container` as mutable, as it is behind a `&` reference
|
|
|
|
unimplemented!();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|