Skip to main content

Pipe

Trait Pipe 

Source
pub trait Pipe<T> {
    // Required method
    fn pipe<F, R>(self, f: F) -> R
       where F: FnOnce(Self) -> R,
             Self: Sized;
}
Expand description

A trait for functional-style method chaining.

Allows any value to be passed through a function, enabling fluent interfaces and functional programming patterns.

Required Methods§

Source

fn pipe<F, R>(self, f: F) -> R
where F: FnOnce(Self) -> R, Self: Sized,

Passes the value through a function.

§Arguments
  • f - Function to apply to the value
§Returns

The result of applying the function to the value

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<T> Pipe<T> for T