Polars: pipe() function for lazy frames

How can I chain operations on a Polars LazyFrame in Rust, similar to Python's .pipe() functionality?
I'm looking to refactor ~250 lines of operations into separate functions, but the Rust API doesn't seem to have an equivalent to Python's polars.LazyFrame.pipe().

What's the idiomatic way to achieve this in Rust?
Python Link: polars.LazyFrame.pipe — Polars documentation

Can't you achieve the same with LazyFrame::map?

As far as I understand, this function does not do anything specific to the object type. You can use the Pipe trait from tap.

Nice! What Bruecki suggested worked:

use std::ops::Add;
use std::path::PathBuf;

use polars::lazy::dsl::*;
use polars::lazy::prelude::*;
use polars::prelude::*;
use tap::Pipe;

impl Reader {
    // Private helper function - only visible within this module
    fn select_path_columns_helper(lf: LazyFrame) -> LazyFrame {
        lf.select([
            col(mc::PATH_KEY),
            col(mc::NODE_SEQUENCE),
            // ... rest of your selection logic
        ])
    }

    // Public method that uses the private helper
    pub fn paths_df(&mut self) -> Result<&DataFrame, PolarsError> {
        if self.paths_df.is_none() {
            let raw_df = self.read_raw_path_df()?;

            let df = raw_df
                .lazy()
                .pipe(Self::select_path_columns_helper)
                .collect()
                .unwrap();
            // ...
        }
        // ...
    }
}

It might work, but it does not keep the Lazy Evaluation and then I could just use the .pipe() implemented for eager data frames.

It does. From the docs of LazyFrame::map:

Apply a function/closure once the logical plan get executed.