Add type_info-based example - #9
Conversation
teor2345
left a comment
There was a problem hiding this comment.
Just some very minor nitpicks, none of these are blocking, but it would be nice to tweak them
| #![feature(const_trait_impl)] | ||
| #![feature(splat)] | ||
| #![feature(tuple_trait)] | ||
| #![feature(type_info)] |
There was a problem hiding this comment.
Christmas tree unstable features 😂
https://en.wikipedia.org/wiki/Christmas_tree_packet
There was a problem hiding this comment.
It took a lot to resist adding const generic expressions too...
| dbg!(min(1, 2, 3, 4)); | ||
| // our type_info based alternative is able to accept an arbitrary number of | ||
| // arguments, but practically compilation times will become prohibitively long | ||
| // around 15,000 arguments. |
There was a problem hiding this comment.
Of course you tested this, nice.
The argument limit for Rust functions is u16::MAX. The position of splat is temporarily limited to u8::MAX for performance, but it can expand to any number of arguments, or have any number of non-splatted arguments after it.
There was a problem hiding this comment.
Yeah I figured if I'm gonna say it supports an arbitrarily large number of arguments, I should actually check it does.
| resolver = "3" | ||
| members = [ | ||
| "cpp-hypot-overload", | ||
| "cpp-hypot-overload", "tuple-reflection", |
There was a problem hiding this comment.
Style nit: I think we are doing each item on a separate line in this file
| "cpp-hypot-overload", "tuple-reflection", | |
| "cpp-hypot-overload", | |
| "tuple-reflection", |
| [package] | ||
| name = "tuple-reflection" | ||
| version.workspace = true | ||
| authors.workspace = true |
There was a problem hiding this comment.
Please add yourself as (the only) author 🙂
| homepage.workspace = true | ||
| keywords.workspace = true | ||
| license.workspace = true | ||
| readme.workspace = true |
There was a problem hiding this comment.
Please add the command to run/test this crate to the README.
Optional: free free to add more description in a new section as well, if you want.
There was a problem hiding this comment.
I decided to just tack it below the other command rather than add a new section. I feel like if you added more examples it might be worth making a section per though.
Demonstrates getting information about the splatted tuple through `type_info` (compile-time reflection), which allows working with arbitrarily large tuples under certain circumstances.
107d71d to
5f3abac
Compare
Demonstrates getting information about the splatted tuple through
type_info(compile-time reflection), which allows working with arbitrarily large tuples under certain circumstances.