to_string is a basic function that tries to generate a minimal magnet_url from a Magnet struct.
The new function was turned into a wrapper of no_new_validation, with the difference being that new makes sure that the magnet str given is a valid magnet url. This should theoretically increase speeds for those who use new_no_validation.
I also added Debug, Clone, Hash, and PartialEq traits to the struct, meaning that the struct is now a little bit more useful in general.
Of course I also added some tests of to_string and the new Traits
When I changed it to just check a str slice against a str, it would never panic since I put in the str wrong, AND I made it so it had t be equal to said str to panic, not the other way around. Yikes.
As one redditor stated, I'm claiming that my program is fast without benchmarks. Here's said benchmark ;). The benchmarks use Criterion and just see how many magnet url's it can make per second. On the sluggish laptop I'm using at the moment, I get around 50K/s.
Removed redundant if statement in lib.rs for the tr field, increasing performance by 40%.
Made it so that the xl field uses a customized match statement for its output, basically making it so it converts from a str to an int, further increasing performance by 11%.
Another helpful redditor warned me about the dangers of not validating
that the URL given is a magnet url. Unfortuanetly, I can't just change
everything to use Options and Errors, so I'm making the fix of having
the library just panic instead, since that would make it still
backwards compatible. This will be changed in version 2.0.0
I added some tests so that I can actually make sure everything works in
the parser. Also made a quick bug fix in any regex that looks for http
links, since they're very likely to be URL encoded.