1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//! Contains the [`DurationValue`] type.
use crate::types::{FExp, Number};
/// A duration value, either a [`Number`] or an [`FExp`](FExp).
///
/// ## Usage
/// Used by [`SimpleDurationConstraint`](crate::SimpleDurationConstraint).
#[derive(Debug, Clone, PartialEq)]
pub enum DurationValue {
/// A numerical value.
Number(Number),
/// A function expression that produces the duration value.
/// ## Requirements
/// Requires [Numeric Fluents](crate::Requirement::NumericFluents).
FExp(FExp),
}
impl DurationValue {
pub fn new_number<I: Into<Number>>(number: I) -> Self {
Self::Number(number.into())
}
pub fn new_f_exp(exp: FExp) -> Self {
Self::FExp(exp)
}
}
impl From<Number> for DurationValue {
fn from(value: Number) -> Self {
Self::Number(value)
}
}
impl From<FExp> for DurationValue {
fn from(value: FExp) -> Self {
Self::FExp(value)
}
}