radareorg / r2pipe.rs

Rust crate for r2pipe
Other
45 stars 19 forks source link

Shave off some code by making the pipe a dyn #46

Closed RHL120 closed 1 year ago

RHL120 commented 1 year ago

Checklist

Description This pr attempts to simplify the r2pipe.rs code by replacing all the variants of the of R2pipe with a single Box that contains a dyn Pipe (pub struct R2Pipe(Box<dyn Pipe>);). This removes the need for the get_pipe method and shaves off about 14 lines of code. On the other hand, This PR may or may not break some code because the R2Pipe enum was public (and so is the new R2pipe struct) so the variants were public too. If this PR is going to cause problems, it would be with R2PipeSpawn because as far as I can tell it is the only struct that has an impl block not for the Pipe trait.

meme commented 1 year ago

I think that this dynamicism is not really necessary and we can use traits instead. However, I'll revisit that at a later date.