openraft 0.10.0-alpha.32

Advanced Raft consensus
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//! Utilities for converting `Result<T, Infallible>` into `T`.

use crate::errors::Infallible;

/// Convert `Result<T, E>` to `T`, if `E` is a `never` type.
pub(crate) fn into_ok<T, E>(result: Result<T, E>) -> T
where E: Into<Infallible> {
    match result {
        Ok(t) => t,
        Err(e) => {
            // NOTE: `allow` required because of buggy reachability detection by rust compiler
            #[allow(unreachable_code)]
            match e.into() {}
        }
    }
}