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
use core::fmt;

use crate::operand::Operand;

/// Represents the [DynamoDB `BETWEEN` operator][1].
///
/// See also: [`Path::between`], [`Key::between`]
///
/// [1]: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Comparators
/// [`Path::between`]: crate::path::Path::between
/// [`Key::between`]: crate::key::Key::between
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Between {
    pub(crate) op: Operand,

    /// Equal to or greater than this value
    pub(crate) lower: Operand,

    /// Equal to or less than this value
    pub(crate) upper: Operand,
}

impl fmt::Display for Between {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        self.op.fmt(f)?;
        f.write_str(" BETWEEN ")?;
        self.lower.fmt(f)?;
        f.write_str(" AND ")?;
        self.upper.fmt(f)
    }
}