ignore_result/
lib.rs

1#![no_std]
2
3#[cfg(test)]
4mod tests;
5
6/// The `Ignore` trait is used to consume the result of a function call
7/// in cases where a function's success or failure is irrelevant, i.e.
8/// in "best effort" scenarios. By consuming the original `Result` and
9/// swallowing its `Ok()` result, it guarantees correctness.
10///
11/// A call to [`Ignore::ignore()`] avoids compiler warnings about unused
12/// results, without requiring a possibly unsafe call to `.unwrap()` if
13/// the success of the preceding function call is not guaranteed.
14pub trait Ignore: Sized {
15    fn ignore(self) -> () {}
16}
17
18impl<T, E> Ignore for Result<T, E> {}