lux_lib/tree/list.rs
1use crate::{lockfile::LocalPackage, tree::InstallTree};
2
3use super::{Tree, TreeError};
4
5// TODO: Due to the whininess of the borrow checker, we resort to cloning package information
6// whenever returning it. In the future, it'd be greatly beneficial to instead return mutable
7// references to the packages, which would allow for in-place manipulation of the lockfile.
8// Cloning isn't destructive, but it's sure expensive.
9
10impl Tree {
11 pub fn as_rock_list(&self) -> Result<Vec<LocalPackage>, TreeError> {
12 let rock_list = self.list()?;
13
14 Ok(rock_list.values().flatten().cloned().collect())
15 }
16}