Skip to main content

join

Function join 

Source
pub fn join<'a, FA, A: 'a, Brand, MidA: 'a>(
    mma: FA,
) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>
where Brand: Kind_cdc7cd43dac7585f, FA: InferableBrand_cdc7cd43dac7585f<'a, Brand, MidA> + JoinDispatch<'a, Brand, A, <FA as InferableBrand_cdc7cd43dac7585f<'a, Brand, MidA>>::Marker>,
Expand description

Removes one layer of monadic nesting, inferring the brand from the container type.

The Brand type parameter is inferred from the single InferableBrand impl on FA. For single-brand types, this resolves uniquely without a closure. For multi-brand types, use explicit::join with a turbofish.

§Type Signature

forall Brand A. Semimonad Brand => Brand (Brand A) -> Brand A

§Type Parameters

  • 'a: The lifetime of the values.
  • FA: The container type (owned or borrowed). Brand is inferred from this.
  • A: The type of the value(s) inside the inner layer.
  • Brand: The brand, inferred via InferableBrand from FA.
  • MidA: The inner container type (e.g., Option<i32> for Option<Option<i32>>), inferred automatically.

§Parameters

  • mma: The nested monadic value (owned or borrowed).

§Returns

A container with one layer of nesting removed.

§Examples

use fp_library::functions::*;

assert_eq!(join(Some(Some(5))), Some(5));

let x = Some(Some(5));
assert_eq!(join(&x), Some(5));