try_append

Function try_append 

Source
pub fn try_append<A: TrySemigroup>(x: A, y: A) -> Result<A, A::Error>
Expand description

Fallibly combine two values.

Free function version that dispatches to the type class’ associated function.

§Type Signature

forall a. TrySemigroup a => (a, a) -> Result a a::Error

§Type Parameters

  • A: The type of the values to combine.

§Parameters

  • x: The first value to combine.
  • y: The second value to combine.

§Returns

The result of combining x and y, or an error.

§Examples

use fp_library::{brands::*, classes::*, functions::*};

let x = String::from("Hello, ");
let y = String::from("World!");
let z = try_append(x, y);
assert_eq!(z, Ok(String::from("Hello, World!")));