collapse icon indicating copy to clipboard operation
collapse copied to clipboard

Restructure Project

Open jbutcher5 opened this issue 2 years ago • 5 comments

A lot of the code base goes against how a Rust project should be structured. For example: The formatting in many places doesn't look write and we should really be using extern crate here.

I would be happy to work on this myself but I recognise that this repo is fairly old and I likely completely inactive

jbutcher5 avatar Apr 23 '22 09:04 jbutcher5

A lot of the code base goes against how a Rust project should be structured.

How? Having both a src/lib.rs and a src/main.rs is maybe unusual, but I've seen it elsewhere, and I don't see anything else strange.

The formatting in many places doesn't look [right]

I suppose you're referring to formatting like

return Err(String::from("Expected the input x and y coordinates to be signed \
                         integers"));

rather than the modern style of

return Err(String::from(
    "Expected the input x and y coordinates to be signed \
    integers"
));

?

I strongly suspect that this code dates from before the modern style was decided. That decision presumably was made through the process of https://github.com/rust-dev-tools/fmt-rfcs, although I'm not seeing where exactly the decision was made. The old style to which you object was formerly common or even standard.

we should really be using extern crate here.

It appears to me to be doing so already: https://github.com/sdleffler/collapse/blob/075f5449bc20ff4ecff9740c90e542f691a8c7f5/src/lib.rs#L1-L12

8573 avatar Apr 23 '22 18:04 8573

If I recall correctly, I wrote most of this code before rustfmt was in widespread usage. Or at the very least I didn’t use it here. I certainly do now; it’s an invaluable tool.

There are a lot of things I remember doing in this project which I would absolutely not do now. Such as a Vec<RefCell<SomethingOrOther>>. It’s been a while but thinking about that now makes me laugh. :P

I keep intending to come back to it and modernize it but I simply have too much on my plate these days. If anyone really wants to take the time to do so, be my guest. It was a fun project to figure out since at the time there weren’t any good explanations on WFC besides the actual C# reference implementation, which was written as if by a formal mathematician (and I believe it was.)

Worth noting that the extern crates also date this back to before edition 2018.

sdleffler avatar Apr 23 '22 18:04 sdleffler

Sorry I meant shouldn't be using extern crate because I seem to remember it to be irrelevant in most places

jbutcher5 avatar Apr 23 '22 20:04 jbutcher5

I am enjoying cleaning up all the small little details that I catch and "modernize" the project however I am still relatively new to Rust myself

jbutcher5 avatar Apr 23 '22 20:04 jbutcher5

Worth noting that the extern crates also date this back to before edition 2018.

I know I'm old-fashioned — I still use it in edition 2021. :-)

There are a lot of things I remember doing in this project which I would absolutely not do now. Such as a Vec<RefCell<SomethingOrOther>>. It’s been a while but thinking about that now makes me laugh. :P

Ah, I was looking only at the ‘project structure’ rather than the data structures.

8573 avatar Apr 24 '22 07:04 8573