Endle / rust-bundler-cp

rust-bundler-cp bundles a cargo package into a single rust file. It's designed for Competitive programming like Codeforces.
https://crates.io/crates/rust_bundler_cp
MIT License
17 stars 6 forks source link

Handle crate names containing hyphens #31

Closed KvGeijer closed 1 year ago

KvGeijer commented 1 year ago

Crates in rust are allowed to contain '-' in their names. But these dashes are all converted to '_' in the code to not confuse the name with subtraction. This commit adds this switch into the code, making it no longer confused for names containing '-'.

As an example, the bundler does not in its current state work for my small competetive Rust template (https://github.com/KvGeijer/comp-rust-template), but it does work after this fix.

KvGeijer commented 1 year ago

I just realized that this is not enough, and does not properly expand use paths. I will look into it further and try to fix it tomorrow.

Endle commented 1 year ago

Thank you! I'm sorry that I'm too busy this week. When I have time, I'll have a look at it too.

Besides, can you add a LICENSE (MIT compatible) to https://github.com/KvGeijer/comp-rust-template? So I could include your template as a test case of rust-bundler-cp, and my further changes will be less likely to break your template.

KvGeijer commented 1 year ago

Thank you for your help. I now added a test case to this pr, which has the same format as the old "simple" test, but now with a hyphen in the crate name to see that it is handled. Works with this commit, but not on the old one.

I also looked into the code a bit more and understood my problem a bit more from last time, and realized that it is unrelated to this pr. I'll try to fix that (it is not a bug, just a limitation that I think could be removed) in another pr, which you can see if you agree with.

Finally, I added an MIT license to my template repo, and if you want to use it, you are very welcome. However, it will still not work with the bundler due to the other thing I mentioned above.

No stress with the pr. Have a good week!

Endle commented 1 year ago

This change has been published on crates.io https://crates.io/crates/rust_bundler_cp/0.3.16

Thank you so much for your PR with a detailed and clear commit message :)

KvGeijer commented 1 year ago

Thank you for your help, and the work maintaining this crate.