Add the Ctor! convenience/abstraction macro we've talked about.
#149
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add the
Ctor!convenience/abstraction macro we've talked about.The purpose of this macro is to hide the impl trait. This makes it easier to change over time, and makes the caller interface much easier to work with, requiring less mindless repetitive typing.
We've said that a snippet of C++ should not require 5x as many tokens to type as the Rust equivalent when using Crubit. So specifying that you return a type, where in C++ it's
Foo, in Rust it's-> Ctor<Output=Foo, Error=std::convert::Infallible>. 1 token vs 16 tokens!This CL brings it down to
-> ctor::Ctor![Foo], 8 tokens. That's about as minimal as we can make it. (Fortunately I think the 5x rule was aimed at function calls, not defining functions, or we'd be in trouble!)Note that it doesn't work if you need
use<'a, Self>and such. I tried, but that was really hard to parse if the macro is to have a really even remotely reasonable syntax. (It needs to support both lifetimes and types, and so on.) Instead, opted to just leave them out. They aren't necessary in Rust 2024.