# Rust Golfing Crates

So, i have started creating a golfing library for Rust, as i saw some questions about it here, with some pretty good response. The usual requirement, was usually including the include statement in the byte count, and adding the library in the header of the answer. In Rust this, for me, leads to some other questions.

In Rust, with custom libraries, we usually have to do 3 things.

1. rustc <filename> --extern <name of crate>=<name of library file>.rlib Which essentially is giving an extra argument to the compiler, saying that we want to use the following library, under that specific crate name.

2. extern crate <name of crate>; which makes it possible to access the library, from within the file in context.

3. use <name of crate>::<name of function, or module>::<name of function, if inside module> which puts the code needed in scope.

As you may have guessed, even with the shortest library names possible, and functions outside modules, this very quickly adds some bytes towards the answer if everything is included.

This is where my question comes into play. What actually counts as the include statement? All 3 parts of it, 2. and 3., or just 3.

Also, some answers said that one should add command line parameters towards the byte count. Does this also go for compiler arguments?

Thank you for all feedback, it would be great to have a good standard to live by. :)

• I'm not sure I understand how rust works but, if you can include the library via command line flags you can use it with no byte penalty. You won't be competing against other Rust answers, but that should be expected because you are using a custom library.
– Wheat Wizard Mod
Dec 20 '17 at 20:35
• I was thinking of doing this in Python. I then was like, "What if I added some preprocessing?", and it became a different language entirely. I'm still down that rabbithole, trying to see if I ever find the time to complete that project. Good luck :P Dec 20 '17 at 20:38
• I'm also a little confused about your question "What actually counts as the include statement?". I'm not sure it really matters where the include statement starts and ends. It might help if you included your motivation for this particular question.
– Wheat Wizard Mod
Dec 20 '17 at 20:40
• @WheatWizard I probably couldve made myself clearer, but the first 2 lines, are actually linking it to the compiler, rather than including/importing as seen in python. So, i guess my question is essentially: Do i have to add the byte penalty for linking a library? Dec 20 '17 at 20:51
• @HavardNygard If it's anything like in Clean, where you can get the same result if you put the library source in the same folder as the golfed source file, I'd say no. Dec 20 '17 at 21:54
• Considering it dosent compete against other rust answers either way, i guess it dosent matter all that much. I may also just end up creating a new interperated language all together though. Dec 21 '17 at 9:10

# Anything in the file counts

In general (meaning with the rare expection if any) the score of an answer should be the size of the file used to store it. This is nice and simple and easy to follow.

### Wait does that mean command line flags are scored?

Maybe, maybe not. The community seems to be in the middle of deciding whether or not to score command line arguments, as I linked in the comments.

Personally, I have stopped scoring them myself, but I think right now that might be more of a personal choice then something the meta will tell you.

Ok now this might not be the answer you were looking for, as it stands you are going to have to lose a ton of bytes every time you want to use your library. Here are my suggestions:

1. Remember that you are not competing against other rust answers. A language plus a custom library is a different language. When I golf I'm almost always competing against myself, I think most of the fun is doing the best you can with the tools you have not necessarily beating others. Just because your golfing library may have a permanent penalty doesn't mean that you can't have fun trying to make your answers shorter.

That suggestion might not be the best, if you are still unsatisfied, here is a more concrete suggestion:

1. Make a "new language". Pietu1998 commented on something similar to this, but since every answer in rust + Håvard's golfing library will have the same boiler plate you can just make a new language with a "compiler" that adds the boiler plate to whatever you feed it. If you want to get really fancy you might modify the existing rust compiler so that it includes your functions by default. This will prevent you from ever having to score those bytes.

(I now see you commented something to this extent right before I finished this answer. Hopefully that means this solution works for you.)

I hope that clarifies a few things and I hope that you can find a resolution that satisfies you.