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
use nom::{
bytes::complete::tag,
character::complete::space1,
combinator::map,
sequence::{separated_pair, tuple},
IResult,
};
use crate::{account::account, date::date, Account, Date};
#[derive(Debug, Clone)]
pub struct Close<'a> {
date: Date,
account: Account<'a>,
}
impl<'a> Close<'a> {
#[must_use]
pub fn date(&self) -> Date {
self.date
}
#[must_use]
pub fn account(&self) -> &Account<'a> {
&self.account
}
}
pub(crate) fn close(input: &str) -> IResult<&str, Close<'_>> {
map(
separated_pair(date, tuple((space1, tag("close"), space1)), account),
|(date, account)| Close { date, account },
)(input)
}