Oddbean new post about | logout
 Unlike c++, in #rust, function and struct declaration order does not matter.
What is the best practice then? From lower-level (no deps) to higher-level (all deps) like in c++? Or the reverse so that you start reading a file from the higher level code? #asknostr #devstr 
 My preference would be struct declaration first, it makes much more sense when reading the code.  
 And between functions? 
 I wouldn't. I'm old school I guess, I prefer everything up front.  
 Structs all to front gives you an idea of what you're working with.

What about pub vs private structs /functions? 
 when having several structs I'd say it's mostly prettier moving them to their own files, because then you can use the filename to re-find your structs. 
 I do this. Structs above impls and functions. 

New structs that come unto scope below existing functions but above functions that use them.

There's while folder and module structure you can consider too for organization.  
 Consistency across a code base is probably more important. Also, if C++ has a paradigm that is more organizational with little impact on code logic, probably fine to use it.

TIL c++ has ordering requirements. Makes me happy I started with Rust for systems stuff.  
 It's not that bad since it sets an expected order. I always start reading c++ files from the bottom up. 
 Good to know. I'll do this when I encounter c++ now 
 I prioritise readability which generally means higher level first 
 Absolute Chaos. 
 Found the JS dev 👆 🤣 jk 
 🌝

It actually doesn't matter in a lot more languages. 
I was kidding tho. Kind of.  
 I am a weirdy, I guess. I prefer to do struct/enum first with method/functions/impls associated with the struct following, then add the next struct, etc.