sommerfeld @sommerfeld - 5mo
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
And between functions?
It's not that bad since it sets an expected order. I always start reading c++ files from the bottom up.
Found the JS dev 👆 🤣 jk
mleku @mleku - 5mo
lol, literally it doesn't matter putting them in the same file is probably the most important thing, sometimes it is more logical to put the most dependent declaration first other times maybe better to show them in order the compiler parses them all at once and sorts them in order of dependency so you are free to put the helpers before or after as you see fit part of the reason why more modern languages do this is because it makes the initial pass on each source file faster, literally just split the file based on sentinel markers, usually a newline and some keyword, like in #golang it's func, var, const, import, type i mean, should you define the types before the methods? usually the most useful thing to put at the top of a file is where the central point of documentation also will go, so you put struct and type definitions at the top and then readers can get the top down view of the package immediately nostr:nevent1qvzqqqqqqypzp5x7h70mzt00s86r6lrfg2dm0pyp9tq7f5k48gszmd42cl4yk3nvqqstjvk47qrlpjke36vyy905ee0fa9saw6f046kt93dsfsfkcfpwhvq0tqwkc