tuwunel_core/utils/result/and_then_ref.rs
1use super::Result;
2
3pub trait AndThenRef<T, E> {
4 fn and_then_ref<U, F>(self, op: F) -> Result<U, E>
5 where
6 F: FnOnce(&T) -> Result<U, E>;
7}
8
9impl<T, E> AndThenRef<T, E> for Result<T, E> {
10 #[inline]
11 fn and_then_ref<U, F>(self, op: F) -> Result<U, E>
12 where
13 F: FnOnce(&T) -> Result<U, E>,
14 {
15 self.and_then(|t| op(&t))
16 }
17}