Module frunk::validated[][src]

Expand description

Module for holding Validated logic

Validated is a way of running a bunch of operations that can go wrong (for example, functions returning Result<T, E>) and, in the case of one or more things going wrong, having all the errors returned to you all at once. In the case that everything went well, you get an HList of all your results.


extern crate frunk;

use frunk::Validated;
use frunk::prelude::*; // for .into_validated()

#[derive(PartialEq, Eq, Debug)]
struct Person {
    age: i32,
    name: String,

fn get_name() -> Result<String, String> {

fn get_age() -> Result<i32, String> {

let v: Validated<HList!(String, i32), String> = get_name().into_validated() + get_age();
let person = v.into_result()
               .map(|hlist_pat!(name, age)| {
                    Person {
                        name: name,
                        age: age,

            Person {
                name: "James".to_owned(),
                age: 32,


A Validated is either an Ok holding an HList or an Err, holding a vector of collected errors.


Trait for “lifting” a given type into a Validated