Skip to main content

PipeRef

Trait PipeRef 

Source
pub trait PipeRef<const ARITY: usize, AState, RState> {
    // Provided method
    fn pipe_ref<'a, R, F, Args>(&'a mut self, f: F) -> F::Curry<'a>
       where F: ImplCurryRef<ARITY, Args, AState, RState, Self, R> { ... }
}
Expand description

Extension trait for safe re-borrowing chains.

Provided Methods§

Source

fn pipe_ref<'a, R, F, Args>(&'a mut self, f: F) -> F::Curry<'a>
where F: ImplCurryRef<ARITY, Args, AState, RState, Self, R>,

Transforms a mutable reference into a borrowed value (or sub-reference).

This is useful for drilling down into a data structure without taking ownership.

§Example
fn first_mut(arr: &mut [i32; 3]) -> &mut i32 { &mut arr[0] }

let mut data = [10, 20, 30];
*data.pipe_ref(first_mut)() = 99;
assert_eq!(data[0], 99);

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<const ARITY: usize, AState, RState, T> PipeRef<ARITY, AState, RState> for T