///|
fn same_delivery(left : Action, right : Action) -> Bool {
match (left, right) {
(Redirect(a), Redirect(b)) =>
match (parse_mailbox(a), parse_mailbox(b)) {
(Some(x), Some(y)) => x.localpart == y.localpart && x.domain == y.domain
_ => a == b
}
(FileInto(a), FileInto(b)) =>
a == b || (ascii_lower(a) == "inbox" && ascii_lower(b) == "inbox")
_ => left == right
}
}
///|
pub fn Plan::has_delivery(self : Plan) -> Bool {
self.actions.any(action => {
match action {
Discard => false
_ => true
}
})
}
///|
pub fn Plan::redirect_targets(self : Plan) -> Array[String] {
self.actions.filter_map(action => {
match action {
Redirect(target) => Some(target)
_ => None
}
})
}