Refactor Request/Resonse's TryFrom impl by generating match stmt#109
Conversation
|
I wonder if this is worth doing until Just a thought, I'll still work on resolving the issues. |
|
So you think the existing code was actually more readable? I have to say I'm not entirely convinced about the changes so far either.. :/ |
|
Yeah, I guess after tinkering with it I would say it was more readable before. My preference (for readability) would be putting as big a code block as possible inside the |
|
Okay. Do you think the |
|
Removing the inner quote! {
let request_body: RequestBody =
ruma_api::try_deserialize!(
ruma_api::exports::serde_json::from_slice(request.body().as_slice()),
::ruma_api::error::RequestDeserializationError,
);
}Or |
|
I think |
| ($kind:ident, $call:expr $(,)*) => { | ||
| ::ruma_api::try_deserialize!(@ $kind, $kind, $call) | ||
| }; | ||
| (@ request, $kind:ident, $call:expr) => { |
There was a problem hiding this comment.
Nice, you made it work! :)
I think the way I've seen this written usually is like this: @request, so without the extra space. Where did you get the idea with the @?
There was a problem hiding this comment.
I remember reading somewhere that the @ was meant to signal internal details of the macro, if you meant with spaces I probably added that as I can't remember exactly where I saw that.
I was surprised that doubling the token $kind, $kind actually worked. Did you have a specific technique in mind?
There was a problem hiding this comment.
I remember reading somewhere that the
@was meant to signal internal details of the macro
Okay :)
Yeah that's what I use too and would basically be my reasoning as well. So no, I didn't have anything else in mind, just the same thing without the extra space, like you've implemented now.
I was surprised that doubling the token
$kind, $kindactually worked.
Why not? ^^
jplatte
left a comment
There was a problem hiding this comment.
CI failed because of formatting, please fix.
No description provided.