Skip to content

Commit

Permalink
Updates generated code template to conform with rust 1.53 lints
Browse files Browse the repository at this point in the history
These will become hard errors in the future
See <rust-lang/rust#79202>
  • Loading branch information
Alyssa Ingersoll committed Jul 1, 2021
1 parent 5d01503 commit a9c9d9c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
34 changes: 17 additions & 17 deletions src/gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,8 @@ mod tests {
"#;

let expected = "
#[serde(default)]
#[derive(Debug, PartialEq, Clone, serde::Deserialize, serde::Serialize)]
#[serde(default)]
pub struct Test {
pub a: i64,
pub b: String,
Expand Down Expand Up @@ -375,8 +375,8 @@ impl Default for Test {

let expected = r#"
/// Hi there.
#[serde(default)]
#[derive(Debug, PartialEq, Clone, serde::Deserialize, serde::Serialize)]
#[serde(default)]
pub struct User {
pub name: String,
pub favorite_number: i32,
Expand Down Expand Up @@ -454,8 +454,8 @@ impl Default for User {
"#;

let expected = r#"
#[serde(default)]
#[derive(Debug, PartialEq, Clone, serde::Deserialize, serde::Serialize)]
#[serde(default)]
pub struct Variable {
pub oid: Option<Vec<i64>>,
pub val: Option<String>,
Expand All @@ -470,8 +470,8 @@ impl Default for Variable {
}
}
#[serde(default)]
#[derive(Debug, PartialEq, Clone, serde::Deserialize, serde::Serialize)]
#[serde(default)]
pub struct TrapV1 {
pub var: Option<Vec<Variable>>,
}
Expand All @@ -484,8 +484,8 @@ impl Default for TrapV1 {
}
}
#[serde(default)]
#[derive(Debug, PartialEq, Clone, serde::Deserialize, serde::Serialize)]
#[serde(default)]
pub struct V1 {
pub pdu: Option<TrapV1>,
}
Expand All @@ -498,8 +498,8 @@ impl Default for V1 {
}
}
#[serde(default)]
#[derive(Debug, PartialEq, Clone, serde::Deserialize, serde::Serialize)]
#[serde(default)]
pub struct Snmp {
pub v1: Option<V1>,
}
Expand Down Expand Up @@ -547,8 +547,8 @@ impl Default for Snmp {
"#;

let expected = r#"
#[serde(default)]
#[derive(Debug, PartialEq, Clone, serde::Deserialize, serde::Serialize)]
#[serde(default)]
pub struct KsqlDataSourceSchema {
#[serde(rename = "ID")]
pub id: Option<String>,
Expand Down Expand Up @@ -598,8 +598,8 @@ pub enum UnionStringLongDoubleBoolean {
Boolean(bool),
}
#[serde(default)]
#[derive(Debug, PartialEq, Clone, serde::Deserialize, serde::Serialize)]
#[serde(default)]
pub struct Contact {
pub extra: ::std::collections::HashMap<String, Option<UnionStringLongDoubleBoolean>>,
}
Expand Down Expand Up @@ -639,8 +639,8 @@ impl Default for Contact {
"#;

let expected = r#"
#[serde(default)]
#[derive(Debug, PartialEq, Clone, serde::Deserialize, serde::Serialize)]
#[serde(default)]
pub struct AvroShortUuid {
#[serde(rename = "mostBits")]
pub most_bits: i64,
Expand All @@ -664,8 +664,8 @@ pub enum UnionStringAvroShortUuid {
AvroShortUuid(AvroShortUuid),
}
#[serde(default)]
#[derive(Debug, PartialEq, Clone, serde::Deserialize, serde::Serialize)]
#[serde(default)]
pub struct AvroFileId {
pub id: UnionStringAvroShortUuid,
}
Expand Down Expand Up @@ -708,8 +708,8 @@ pub enum UnionStringLongDoubleBoolean {
Boolean(bool),
}
#[serde(default)]
#[derive(Debug, PartialEq, Clone, serde::Deserialize, serde::Serialize)]
#[serde(default)]
pub struct Contact {
pub extra: ::std::collections::HashMap<String, Option<UnionStringLongDoubleBoolean>>,
}
Expand Down Expand Up @@ -752,8 +752,8 @@ impl Default for Contact {
"#;

let expected = r#"
#[serde(default)]
#[derive(Debug, PartialEq, Clone, serde::Deserialize, serde::Serialize)]
#[serde(default)]
pub struct AvroShortUuid {
#[serde(rename = "mostBits")]
pub most_bits: i64,
Expand All @@ -777,8 +777,8 @@ pub enum UnionStringAvroShortUuid {
AvroShortUuid(AvroShortUuid),
}
#[serde(default)]
#[derive(Debug, PartialEq, Clone, serde::Deserialize, serde::Serialize)]
#[serde(default)]
pub struct AvroFileId {
pub id: UnionStringAvroShortUuid,
}
Expand Down Expand Up @@ -826,8 +826,8 @@ macro_rules! deser(
);
);
#[serde(default)]
#[derive(Debug, PartialEq, Clone, serde::Deserialize, serde::Serialize)]
#[serde(default)]
pub struct Test {
#[serde(deserialize_with = "nullable_test_a")]
pub a: i64,
Expand Down Expand Up @@ -868,8 +868,8 @@ impl Default for Test {
);
);

#[serde(default)]
#[derive(Debug, PartialEq, serde::Deserialize, serde::Serialize)]
#[serde(default)]
pub struct Test {
#[serde(deserialize_with = "nullable_test_a")]
pub a: i64,
Expand Down Expand Up @@ -964,8 +964,8 @@ impl Default for Test {
schema_b_file.write_all(schema_b_str.as_bytes())?;

let expected = r#"
#[serde(default)]
#[derive(Debug, PartialEq, Clone, serde::Deserialize, serde::Serialize)]
#[serde(default)]
pub struct B {
pub field_one: A,
}
Expand All @@ -978,8 +978,8 @@ impl Default for B {
}
}
#[serde(default)]
#[derive(Debug, PartialEq, Clone, serde::Deserialize, serde::Serialize)]
#[serde(default)]
pub struct A {
pub field_one: f32,
}
Expand Down
10 changes: 5 additions & 5 deletions src/templates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ pub const RECORD_TEMPLATE: &str = r#"
{%- if doc %}
/// {{ doc }}
{%- endif %}
#[serde(default)]
#[derive(Debug, PartialEq, Clone, serde::Deserialize, serde::Serialize)]
#[serde(default)]
pub struct {{ name }} {
{%- for f in fields %}
{%- set type = types[f] %}
Expand Down Expand Up @@ -1223,8 +1223,8 @@ mod tests {
"#;

let expected = r#"
#[serde(default)]
#[derive(Debug, PartialEq, Clone, serde::Deserialize, serde::Serialize)]
#[serde(default)]
pub struct User {
pub r#as: String,
#[serde(rename = "favoriteNumber")]
Expand Down Expand Up @@ -1277,8 +1277,8 @@ impl Default for User {
"#;

let expected = r#"
#[serde(default)]
#[derive(Debug, PartialEq, Clone, serde::Deserialize, serde::Serialize)]
#[serde(default)]
pub struct User {
#[serde(rename = "m-f64")]
pub m_f64: ::std::collections::HashMap<String, f64>,
Expand Down Expand Up @@ -1323,8 +1323,8 @@ impl Default for User {
"#;

let expected = r#"
#[serde(default)]
#[derive(Debug, PartialEq, Clone, serde::Deserialize, serde::Serialize)]
#[serde(default)]
pub struct User {
pub info: Info,
}
Expand Down Expand Up @@ -1417,8 +1417,8 @@ pub type Md5 = [u8; 16];
let res = templater.str_record(&schema, &gs).unwrap();

let expected = "
#[serde(default)]
#[derive(Debug, PartialEq, Clone, serde::Deserialize, serde::Serialize)]
#[serde(default)]
pub struct Contact {
pub extra: Option<UnionStringLongDoubleBoolean>,
}
Expand Down

0 comments on commit a9c9d9c

Please sign in to comment.