Skip to main content

rx_rust/disposable/
either_disposal.rs

1use crate::disposable::Disposable;
2use educe::Educe;
3
4#[derive(Educe)]
5#[educe(Debug, Clone)]
6pub enum EitherDisposal<D1, D2> {
7    Left(D1),
8    Right(D2),
9}
10
11impl<D1, D2> Disposable for EitherDisposal<D1, D2>
12where
13    D1: Disposable,
14    D2: Disposable,
15{
16    fn dispose(self) {
17        match self {
18            EitherDisposal::Left(d) => d.dispose(),
19            EitherDisposal::Right(d) => d.dispose(),
20        }
21    }
22}