Created
February 1, 2026 02:08
-
-
Save Zomatree/d197e777810e3d98ebda8696073e59cf to your computer and use it in GitHub Desktop.
partials
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| macro_rules! generate_field_diff { | |
| (optional, $self:ident, $before:ident, $partial:ident, $field:ident) => { | |
| if $partial.$field.is_some() { | |
| $before.$field = $self.$field.clone(); | |
| }; | |
| }; | |
| ($self:ident, $before:ident, $partial:ident, $field:ident) => { | |
| if $partial.$field.is_some() { | |
| $before.$field = Some($self.$field.clone()); | |
| }; | |
| }; | |
| } | |
| macro_rules! generate_diff { | |
| ( | |
| $self:ident, | |
| $before:ident, | |
| $partial:ident, | |
| ( | |
| $( | |
| $( | |
| $(@$optional:tt)? (optional) | |
| )? | |
| $field: ident | |
| ),+ | |
| $(,)? | |
| ) | |
| ) => { | |
| $( | |
| generate_field_diff!($( $($optional)? optional,)? $self, $before, $partial, $field); | |
| )* | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment