finchers_ext/
left.rs

1#![allow(missing_docs)]
2
3use finchers_core::endpoint::{Context, Endpoint, IntoEndpoint};
4
5pub fn new<E1, E2>(e1: E1, e2: E2) -> Left<E1::Endpoint, E2::Endpoint>
6where
7    E1: IntoEndpoint,
8    E2: IntoEndpoint,
9{
10    Left {
11        e1: e1.into_endpoint(),
12        e2: e2.into_endpoint(),
13    }
14}
15
16#[derive(Debug, Copy, Clone)]
17pub struct Left<E1, E2> {
18    e1: E1,
19    e2: E2,
20}
21
22impl<E1, E2> Endpoint for Left<E1, E2>
23where
24    E1: Endpoint,
25    E2: Endpoint,
26{
27    type Output = E1::Output;
28    type Task = E1::Task;
29
30    fn apply(&self, cx: &mut Context) -> Option<Self::Task> {
31        let f1 = self.e1.apply(cx)?;
32        drop(self.e2.apply(cx)?);
33        Some(f1)
34    }
35}