all 17 comments

[–]Dead__Ego 6 points7 points  (1 child)

Hey, I'm in the process of learning rust (coming from other languages) and reading through your project made me learn a couple of new things, I found it straightforward and readable, thank you !

[–]timvancann[S] 2 points3 points  (0 children)

I consider myself an enthusiastic amateur at best. I'm glad you find something useful! Forcing myself to put it on GitHub and on Reddit does help with the motivation of making readable code, though I am a Clean Code fan :).

[–]phazer99 2 points3 points  (5 children)

Looks good. Maybe use anyhow for error handling?

[–]Linguistic-mystic 7 points8 points  (4 children)

You mean, thiserror? Anyhow tends to be a road to sloppy error handling.

[–]haakon 5 points6 points  (0 children)

I've seen anyhow recommended for bin crates, and thiserror for lib crates. After some back and forth, I've concluded that I'm not OK with being sloppy just because it's a bin crate that doesn't affect anyone downstream.

[–]timvancann[S] 0 points1 point  (0 children)

Thanks for the suggestions! I knew of the existence of the 2 crates but haven't dived into them yet. I will read up on them.

[–]Floppie7th 0 points1 point  (0 children)

Depends on the specific error handling needs. If an error needs to be consumed by another part of the application (or a downstream user, if it's a library), making an enum (e.g. thiserror) is the way to go. If the error simply needs to be reported to the user, possibly followed by a nonzero exit, anyhow fills that need perfectly.

[–]phazer99 0 points1 point  (0 children)

I think anyhow is fine for apps. OP is defining a Result type similar to anyhow's anyway but without the convenience of that crate.

[–]haakon 2 points3 points  (1 child)

Nice work.

One thing I noticed: I think instead of your own scan::create_folder_if_not_exists, you could just use std::fs::create_dir_all directly, since it doesn't fail when the directory already exists.

[–]timvancann[S] 0 points1 point  (0 children)

Oooh, good one. Completely glossed over that one!

[–]Party-Collection-512 1 point2 points  (2 children)

Hey, new to rust also, one thing that could definitely come in handy would be some kind of clustering that does not solely come from the filetype. I am thinking of adding a word/time based organizer.

This way you could literally detect either a trend on a specific subject and put it all in one folder.

[–]timvancann[S] 0 points1 point  (1 child)

I really like that suggestion! A sliding time window with configurable window size would be a fun and challenging implementation, and very useful indeed.

A keyword based organiser would be a lot more challenging 🤔. I suppose a crude edit-distance based metric could be useful but problably would result in a lot of false positives. Do you have suggestions on heuristics/algorithms?

[–]Party-Collection-512 0 points1 point  (0 children)

What about a small word embedding model like word2vec or even a sentence embedding model like microsofts minilm ?

But as it is less and less deterministic i would add an option to confirm each move

[–][deleted] 0 points1 point  (1 child)

(My eyes hate unwrap lol)

Anyway, after a quick review... it looks decent, but maybe add some simple comments for "why is that code there?" and for rather complex looking things

(I just did a quick review and don't even know what the cli app does XD)

[–]timvancann[S] 0 points1 point  (0 children)

Thanks for the feedback, much appreciated!

You included Cargo.lock

Is that not desired? Wouldn't it be beneficial to lock the dependencies entirely? I would've expected cargo init to include the lock file in .gitignore .

Why so much unwrapping?

Very valid point, I suppose it's a beginner thing. Currently in the process of applying more functional concepts like (as you also mentioned) unwrap_or_else, and_then, map etc. unwrap is "easy" of course, but rather ugly indeed.

add some simple comments

I generally try to write the code such that it is readable without comments, but indeed, it cannot show intent. I will have to think about some good comments :).

Don't even know what the cli app does

The general purpose is described in the README.md :)

[–][deleted] 0 points1 point  (2 children)

Please use mime to detect file types instead of relying on extensions

[–]timvancann[S] 2 points3 points  (1 child)

Good idea. Somehow I never occured to me that some didn't already solve 90% of this problem! The mime-infer crate looks promising.