this post was submitted on 18 Aug 2023
26 points (93.3% liked)
Rust
5981 readers
51 users here now
Welcome to the Rust community! This is a place to discuss about the Rust programming language.
Wormhole
Credits
- The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Functions are fine, don't move to struct impls unless it makes sense (but do if the functions all take the same struct as a param).
You can go pretty far with modules and functions. Group related functions and move them to new modules. You can also hide functions that are only used inside one of the submodules by just not marking them as
pub
.One thing that comes to mind is that if the steps of your algorithm all take and return the same data, you can have a trait that expresses that (possibly one of the
Fn
traits if you're going to just use functions), and you can define and rest each step separately.It's hard to give more concrete advice without knowing more about your project