Created
February 13, 2019 13:55
-
-
Save sgrif/38f5e9dc49fed32bc300d7a374a144ba to your computer and use it in GitHub Desktop.
This file contains 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
// mutable state | |
let mut sql_type = None; | |
let mut sql_type_ref = None; | |
if !type_args.is_empty() { | |
sql_type = Some(quote!((#(#type_args),*))); | |
sql_type_ref = Some(quote!((#(&'a #type_args),*))); | |
} |
This file contains 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
// repetition | |
let sql_type = if type_args.is_empty() { | |
None | |
} else { | |
Some(quote!((#(#type_args),*))) | |
}; | |
let sql_type_ref = if type_args.is_empty() { | |
None | |
} else { | |
Some(quote!((#(&'a #type_args),*))) | |
} |
This file contains 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
// tuple assignment | |
let (sql_type, sql_type_ref) = if type_args.is_empty() { | |
(None, None) | |
} else { | |
( | |
Some(quote!((#(#type_args),*))), | |
Some(quote!((#(&'a #type_args),*))), | |
) | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment