I'w writing a program in Rust that basically pushes data through a pipeline of steps that transforms it in different ways. The data is represented by an
Entry, and I am designing a
Step trait for the steps in the pipeline.
The trait should have a method that process the entry. My first design was this:
fn process(&self, entry: &mut Entry) -> ()
Later, I realize I wanted some steps to be able to drop the entry, i.e. somehow signal to the caller that the entry should not be processed any further through the pipeline. I am considering two different signatures for this:
fn process(&self, entry: Entry) -> Option<Entry> //Returns None if object is dropped.
fn process(&self, entry: &mut Entry) -> bool //Returns false if object is dropped.
Which one would you say is the most idiomatic and cleanest? Is there any performance penalty in passing the ownership around as in the first option? Is there a third better alternative?