2019-11-21 06:23:32 -08:00
|
|
|
use crate::common::*;
|
|
|
|
|
2021-11-17 00:07:48 -08:00
|
|
|
#[derive(PartialEq, Debug, Serialize)]
|
2019-12-07 04:03:03 -08:00
|
|
|
pub(crate) struct Dependency<'src> {
|
|
|
|
pub(crate) arguments: Vec<Expression<'src>>,
|
2021-11-17 00:07:48 -08:00
|
|
|
#[serde(serialize_with = "keyed::serialize")]
|
|
|
|
pub(crate) recipe: Rc<Recipe<'src>>,
|
2019-12-07 04:03:03 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<'src> Display for Dependency<'src> {
|
|
|
|
fn fmt(&self, f: &mut Formatter) -> Result<(), fmt::Error> {
|
|
|
|
if self.arguments.is_empty() {
|
|
|
|
write!(f, "{}", self.recipe.name())
|
|
|
|
} else {
|
|
|
|
write!(f, "({}", self.recipe.name())?;
|
|
|
|
|
|
|
|
for argument in &self.arguments {
|
|
|
|
write!(f, " {}", argument)?;
|
|
|
|
}
|
|
|
|
|
|
|
|
write!(f, ")")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|