Off-topic mostly, but is this sort of "single line" function/macro typical for Rust crates? This seems like something I would expect from a Node library, not a serious programming language community that cares about robust software.
Macros can be quite hard to understand, so having a simple crate wrapping it with extensive documentation and tests can be quite beneficial. And yes, this also applies to node. The attack is entirely unnecessary.
This crate has no tests, and no documentation beyond a usage example; it would do much better as a copy/paste than an entire dependency, in any ecosystem. It would be great to have as part of some extended "utils" package if it can't be included in the standard library (something like C++'s boost or Java's Apache Commons).
I think this is a valid question. C++ provides std::is_same<U, T>, why do Rust users need an external dependency (especially given the fact that the type system is one of Rust's major strengths)?
My best guess, going by a comment in the source code, is that this macro will not be necessary in the future, and therefore makes less sense to put in the standard library:
> Until RFC 1977 (public dependencies) is accepted, the situation where multiple different versions of the same crate are present is possible.
That isn't a single line macro. Did you mean a single macro crate? Most crates in rust have more than a single macro/function, but some do. Regardless, it's not at all related to how "robust" or not the language ecosystem is.
It's 17 lines of code (11 if you don't count the white space). If you find it somewhere and copy it to your utils package, that's great! If you add a dependency for every little utility you may need, you're going to end up with huge space for ecosystem attacks, as we're seeing in the Node ecosystem. Especially for something like this, where people can add it as a dependency because they don't want to understand macro code (there is another comment saying just that).
I've looked at it, that is why I knew it is very little code. It's definitely something I'd copy off StackOverflow if I really needed it, but to include it as a dependency is just weird.
Normally this would be a compile time error, but using typeid can turn this into a runtime error.
https://docs.rs/assert-type-eq/0.1.0/assert_type_eq/ allows you to assert that two types are the same, forcing a compile time error for this scenario.