Function pr47::util::type_assert::assert_result[][src]

pub const fn assert_result<T>() where
    Void: AssertResult<T>, 
Expand description

Assert that the type parameter T is an exception-convertible Result type.

// Succeeds because std::result::Result<(), Box<dyn std::error::Error>> is convertible
pr47::util::type_assert::assert_result::<Result<(), Box<dyn std::error::Error>>>();
// Fails because std::fs::OpenOptions is not Result type
pr47::util::type_assert::assert_result::<std::fs::OpenOptions>();
struct Result<T, E>(std::marker::PhantomData<(T, E)>);
// Fails because this Result is not std::result::Result
pr47::util::type_assert::assert_result::<Result<(), Box<dyn std::error::Error>>>();
fn foo<'a>() {
    // Fails because the error type used is not 'static
    pr47::util::type_assert::assert_result::<Result<(), &'a i64>>();
}