1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#![cfg_attr(not(feature = "std"), no_std)]
pub mod fmt;
pub mod indentable;
#[cfg(feature = "std")]
pub mod io;
trait Inspect<T> {
fn inspect(self, func: impl FnOnce(&T)) -> Self;
}
impl<T> Inspect<T> for Option<T> {
#[inline]
fn inspect(self, func: impl FnOnce(&T)) -> Self {
if let Some(ref value) = self {
func(value)
}
self
}
}
impl<T, E> Inspect<T> for Result<T, E> {
#[inline]
fn inspect(self, func: impl FnOnce(&T)) -> Self {
if let Ok(ref value) = self {
func(value)
}
self
}
}