1use rustc_hash::FxHashSet;
2
3use uv_configuration::Upgrade;
4use uv_normalize::PackageName;
5
6#[derive(Debug, Default, Clone)]
10pub struct UpgradePackages {
11 all: bool,
13 packages: FxHashSet<PackageName>,
15}
16
17impl UpgradePackages {
18 pub fn for_non_project(upgrade: &Upgrade) -> Self {
21 match (upgrade.is_all(), upgrade.packages()) {
22 (true, _) => Self {
23 all: true,
24 packages: FxHashSet::default(),
25 },
26 (false, Some(packages)) => Self {
27 all: false,
28 packages: packages.clone(),
29 },
30 (false, None) => Self::default(),
31 }
32 }
33
34 pub fn contains(&self, package_name: &PackageName) -> bool {
36 self.all || self.packages.contains(package_name)
37 }
38}