Ephera, (edited )

I took a very quick look at the code and one thing I noticed, is that you’re using &String.

For a parameter in a function, you always want to use &str instead, as explained here: doc.rust-lang.org/book/ch04-03-slices.html#string…

I believe, it’s also not a thing to return &String (nor to store it in a struct). I don’t have as solid of an explanation for it, it’s just not something I see much in Rust code (and in the chapter above, they do use a &str as return value, too).
Maybe someone else can weigh in on that.

The same applies for:

  • &[] rather than &Vec
  • &Path rather than &PathBuf
  • &OsStr rather than &OsString

I would also recommend using Clippy. I think, you can just run cargo clippy and it’ll work.
It’s a linter and will tell you lots of code style issues (like using &String as a parameter).
If you’ve never run it, it might spit out a lot of warnings at first, but working through them can teach you quite some things.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • rust@programming.dev
  • Durango
  • DreamBathrooms
  • thenastyranch
  • magazineikmin
  • tacticalgear
  • khanakhh
  • Youngstown
  • mdbf
  • slotface
  • rosin
  • everett
  • ngwrru68w68
  • kavyap
  • InstantRegret
  • JUstTest
  • cubers
  • GTA5RPClips
  • cisconetworking
  • ethstaker
  • osvaldo12
  • modclub
  • normalnudes
  • provamag3
  • tester
  • anitta
  • Leos
  • megavids
  • lostlight
  • All magazines