-
-
Notifications
You must be signed in to change notification settings - Fork 154
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
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 |
ruma-api/src/lib.rs
Outdated
($kind:ident, $call:expr $(,)*) => { | ||
::ruma_api::try_deserialize!(@ $kind, $kind, $call) | ||
}; | ||
(@ request, $kind:ident, $call:expr) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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, $kind
actually worked.
Why not? ^^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CI failed because of formatting, please fix.
No description provided.