pub trait PipeDeref {
fn pipe_deref<'a, R>(
&'a self,
func: impl FnOnce(&'a <Self as Deref>::Target) -> R
) -> R
where
Self: Deref,
R: 'a + Sized,
{ ... }
fn pipe_deref_mut<'a, R>(
&'a mut self,
func: impl FnOnce(&'a mut <Self as Deref>::Target) -> R
) -> R
where
Self: DerefMut,
R: 'a + Sized,
{ ... }
}
Expand description
Calls the Deref
or DerefMut
traits before piping.
Provided methods
Pipes a dereference into a function that cannot normally be called in suffix position.
Parameters
&self
: This borrowsself
for the same reasons as described in thefunc
: A function as described in the other methods. This receives the result ofDeref::deref
.
Lifetimes
'a
: The lifetime of theself
value..pipe_mut
borrowsself
for the duration'a
, and extends it through the return value offunc
.
Pipes a mutable dereference into a function that cannot normally be called in suffix position.
Parameters
&mut self
: This mutably borrowsself
for the same reasons as described in the other methods.func
: A function as described in the other methods. This receives the result ofDerefMut::deref
.
Lifetimes
'a
: The lifetime of theself
value..pipe_mut
borrowsself
for the duration'a
, and extends it through the return value offunc
.