Skip to content

Instantly share code, notes, and snippets.

@danburkert
Last active June 16, 2017 08:08
Show Gist options
  • Save danburkert/d3b70b36d4a143af47c9bf56d5ba3ab9 to your computer and use it in GitHub Desktop.
Save danburkert/d3b70b36d4a143af47c9bf56d5ba3ab9 to your computer and use it in GitHub Desktop.
fn main() {
let key_types = &[
("i32", "int32"),
("i64", "int64"),
("u32", "uint32"),
("u64", "uint64"),
("i32", "sint32"),
("i64", "sint64"),
("u32", "fixed32"),
("u64", "fixed64"),
("i32", "sfixed32"),
("i64", "sfixed64"),
("bool", "bool"),
("String", "string"),
];
let val_types = &[
("f32", "float"),
("f64", "double"),
("i32", "int32"),
("i64", "int64"),
("u32", "uint32"),
("u64", "uint64"),
("i32", "sint32"),
("i64", "sint64"),
("u32", "fixed32"),
("u64", "fixed64"),
("i32", "sfixed32"),
("i64", "sfixed64"),
("bool", "bool"),
("String", "string"),
("Vec<u8>", "bytes"),
];
for &(ref key_rust_ty, ref key_pb_ty) in key_types {
for &(ref val_rust_ty, ref val_pb_ty) in val_types {
println!(concat!("map!({key_rust_ty}, {val_rust_ty}, encode_map_{key_pb_ty}_{val_pb_ty}, ",
"merge_map_{key_pb_ty}_{val_pb_ty}, ",
"encoded_len_map_{key_pb_ty}_{val_pb_ty}, ",
"encode_{key_pb_ty}, merge_{key_pb_ty}, encoded_len_{key_pb_ty}, ",
"encode_{val_pb_ty}, merge_{val_pb_ty}, encoded_len_{val_pb_ty}, ",
"test_map_{key_pb_ty}_{val_pb_ty});"),
key_rust_ty=key_rust_ty,
val_rust_ty=val_rust_ty,
key_pb_ty=key_pb_ty,
val_pb_ty=val_pb_ty);
}
}
for &(ref key_rust_ty, ref key_pb_ty) in key_types {
println!(concat!("enumeration_map!({key_rust_ty}, encode_map_{key_pb_ty}_enumeration, ",
"merge_map_{key_pb_ty}_enumeration, ",
"encoded_len_map_{key_pb_ty}_enumeration, ",
"encode_{key_pb_ty}, merge_{key_pb_ty}, ",
"encoded_len_{key_pb_ty}, test_map_{key_pb_ty}_enumeration);"),
key_rust_ty=key_rust_ty,
key_pb_ty=key_pb_ty);
}
for &(ref key_rust_ty, ref key_pb_ty) in key_types {
println!(concat!("message_map!({key_rust_ty}, encode_map_{key_pb_ty}_message, ",
"merge_map_{key_pb_ty}_message, ",
"encoded_len_map_{key_pb_ty}_message, ",
"encode_{key_pb_ty}, merge_{key_pb_ty}, ",
"encoded_len_{key_pb_ty});"),
key_rust_ty=key_rust_ty,
key_pb_ty=key_pb_ty);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment