-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(core): #[command] return with autoref specialization workaround fix #1672 #1734
Conversation
marked as draft until we decide this is the solution we want to use |
async + elided borrow + no return = error fix needed for that use case (e.g. using `State<'_, T>`)
Note: The simple async state command is disabled for now until I look at it again tomorrow. Because Either a way to specify that lifetime better is needed in the underlying code, or a documented workaround to specify that type is needed. |
If intellij-rust/intellij-rust#7214 is closed as wont-fix, then we should add another option to be used. e.g. |
This PR is ready to review - all commands that existed before it work. We should probably make sure that the commands example is fully fleshed out, and that every command in rust has a button on the frontend - but that can wait for another PR. The autoref specialization workaround is what lets us "unwrap" the result of the function if it happens to be |
What kind of change does this PR introduce? (check at least one)
Does this PR introduce a breaking change? (check one)
The PR fulfills these requirements:
fix: #xxx[,#xxx]
, where "xxx" is the issue number)If adding a new feature, the PR's description includes:
Other information:
So we can't really return a trait while also having a default implementation for
Serialize
becauseResult
is alsoSerialize
if the contents are. Since the contents need to beSerialize
to be useful as a command result, the implementations would conflict if we tried to have a specific implementation forResult
. If we don't have a specific implementation for result, the value would be sent asResult<Result<T, E>, InvokeError>
.This is not the only solution, but is the one with the least user-land code needed. An alternative would be to manually
impl
every type thatSerialize
does for aCommandResult
trait, and also require the user to implement it for any types they have that are serializable that they wish to return from commands. Not ideal, but possible.