Skip to content

Instantly share code, notes, and snippets.

@sgrif
Created February 13, 2019 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sgrif/38f5e9dc49fed32bc300d7a374a144ba to your computer and use it in GitHub Desktop.
Save sgrif/38f5e9dc49fed32bc300d7a374a144ba to your computer and use it in GitHub Desktop.
// 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),*)));
}
// 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),*)))
}
// 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