use crate::internal::incompatibility::Incompatibility;
use crate::package::Package;
use crate::term::Term;
use crate::version::Version;
#[derive(Clone)]
pub enum Assignment<P: Package, V: Version> {
Decision {
package: P,
version: V,
},
Derivation {
package: P,
cause: Incompatibility<P, V>,
},
}
impl<P: Package, V: Version> Assignment<P, V> {
pub fn package(&self) -> &P {
match self {
Self::Decision { package, .. } => package,
Self::Derivation { package, .. } => package,
}
}
pub fn as_term(&self) -> Term<V> {
match &self {
Self::Decision { version, .. } => Term::exact(version.clone()),
Self::Derivation { package, cause } => cause.get(&package).unwrap().negate(),
}
}
}