rewrap

Crates.iorewrap
lib.rsrewrap
version1.0.1
sourcesrc
created_at2022-07-30 15:01:36.427055
updated_at2022-07-30 15:12:30.06224
description`Result, F>` -> `Result`
homepage
repositoryhttps://gitlab.com/liqu1dator_mukh/rewrap
max_upload_size
id635573
size3,691
Myxa (myxaaa)

documentation

https://docs.rs/rewrap

README

Rewrap

Ever wanted to convert Result<Result<T, E>, F> into Result<T, F>? No? Anyway...

Installation

cargo add rewrap

Usage

use rewrap::Rewrap;
use thiserror::Error;

#[derive(Error, Debug)]
enum OriginalError {}

#[derive(Error, Debug)]
enum TargetError {
    #[error(transparent)]
    Original(#[from] OriginalError)
}

fn main() {
    let result: Result<(), TargetError> = Ok(());
    let result_of_result: Result<Result<(), TargetError>, OriginalError> = Ok(result);
    let rewrapped_result: Result<(), TargetError> = result_of_result.rewrap();
    let unwrapped_result: () = rewrapped_result.unwrap();
}
Commit count: 7

cargo fmt