fp_library/types/
pair.rs

1//! Implementations for [`Pair`], a type that wraps two values.
2
3pub mod pair_with_first;
4pub mod pair_with_second;
5
6use crate::{
7	classes::{ClonableFn, clonable_fn::ApplyFn},
8	hkt::Kind0L2T,
9};
10pub use pair_with_first::*;
11pub use pair_with_second::*;
12
13/// Wraps two values.
14#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct Pair<First, Second>(pub First, pub Second);
16
17pub struct PairBrand;
18
19impl Kind0L2T for PairBrand {
20	type Output<A, B> = Pair<A, B>;
21}
22
23impl<'a, First, Second> Pair<First, Second>
24where
25	First: 'a + Clone,
26{
27	pub fn new<ClonableFnBrand: 'a + ClonableFn>(
28		first: First
29	) -> ApplyFn<'a, ClonableFnBrand, Second, Self> {
30		ClonableFnBrand::new(move |second| Pair(first.to_owned(), second))
31	}
32}