#Code review request for my project before first release

17 messages · Page 1 of 1 (latest)

copper tree
sweet pike
#

you could probably use a better way of parsing command line args than simply grabbing them in sequence and erroring out if anything is wrong

#

take a look at clap - it's a bit of work to get going but you can have nice defaults, use switches or positional args, ensure the correct type, and so on

#

also not too sure about having a struct full of pub members

#

anything taking &self has access to those members (like your formatting function)

#

anything external to the struct should probably have a specific (and I would suggest immutable seeing as your data needs no processing) way to peep at them as needed

#

anyway I'll leave the rest to someone more experienced, tbh I just dropped in bc my code review was ignored and I didn't want it to happen to everyone else 😄

copper tree
#

ah, thank you

#

I think i'm gonna go with pico-args as my argument parsing lib

copper tree
#

I'm fine making them immutable but idk if it would work if they were private

#

also, aren't the members already immutable?

sweet pike
#

depends if the struct is - by immutable i mean exposing them via functions that return only a reference to them

#

ie. you instantiate them and have no interfaces for modifying them in place

#

that's the "workaround" for them being private - you mediate the access by how you expose them, rather than them acting as a collection of free variables

#

does that make sense?

#

btw i have no criticism for "idiomatic" or not, sorry - the languages intent and best practices are sometimes a tad murky to me. this is just AFAIK best practice for "objects" and it seems to carry across logically to rusts struct/impl style