feat(core): #[command] return with autoref specialization workaround fix #1672 #1734
feat(core): #[command] return with autoref specialization workaround fix #1672 #1734lucasfernog merged 9 commits intodevfrom
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
SerializebecauseResultis alsoSerializeif the contents are. Since the contents need to beSerializeto 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
implevery type thatSerializedoes for aCommandResulttrait, 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.