Skip to content

Commit

Permalink
feat!: remove requirement to Default
Browse files Browse the repository at this point in the history
issue #175 #144
  • Loading branch information
MarcAntoine-Arnaud committed Feb 5, 2024
1 parent 3413e98 commit 82df2e1
Show file tree
Hide file tree
Showing 12 changed files with 190 additions and 159 deletions.
8 changes: 4 additions & 4 deletions examples/src/bbigras_namespace.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// related to issue https://github.com/media-io/yaserde/issues/15
use yaserde::*;

#[derive(YaDeserialize, Default, Debug, PartialEq)]
#[derive(YaDeserialize, Debug, PartialEq)]
#[yaserde(
prefix = "ss",
namespace = "x: urn:schemas-microsoft-com:office:excel",
Expand All @@ -14,7 +14,7 @@ struct Workbook {
worksheet: Worksheet,
}

#[derive(YaDeserialize, Default, Debug, PartialEq)]
#[derive(YaDeserialize, Debug, PartialEq)]
#[yaserde(
prefix = "ss",
namespace = "x: urn:schemas-microsoft-com:office:excel",
Expand All @@ -29,7 +29,7 @@ struct Worksheet {
ws_name: String,
}

#[derive(YaDeserialize, Default, Debug, PartialEq)]
#[derive(YaDeserialize, Debug, PartialEq)]
#[yaserde(
prefix = "ss",
namespace = "x: urn:schemas-microsoft-com:office:excel",
Expand Down Expand Up @@ -57,7 +57,7 @@ struct Table {
rows: Vec<Row>,
}

#[derive(YaDeserialize, Default, Debug, PartialEq)]
#[derive(YaDeserialize, Debug, PartialEq)]
#[yaserde(
prefix = "ss",
namespace = "x: urn:schemas-microsoft-com:office:excel",
Expand Down
26 changes: 13 additions & 13 deletions examples/src/boscop.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// related to issue https://github.com/media-io/yaserde/issues/3
use yaserde::*;

#[derive(Default, Debug, Clone, PartialEq, YaDeserialize)]
#[derive(Debug, Clone, PartialEq, YaDeserialize)]
#[yaserde(root = "layout")]
pub struct Layout {
#[yaserde(attribute)]
Expand All @@ -17,7 +17,7 @@ pub struct Layout {
pub tabpage: Vec<Tabpage>,
}

#[derive(Default, Debug, Clone, PartialEq, YaDeserialize)]
#[derive(Debug, Clone, PartialEq, YaDeserialize)]
pub struct Tabpage {
#[yaserde(attribute, rename = "name")]
pub named: String,
Expand Down Expand Up @@ -48,7 +48,7 @@ pub struct Tabpage {
pub control: Vec<Control>,
}

#[derive(Default, Debug, Clone, PartialEq, YaDeserialize)]
#[derive(Debug, Clone, PartialEq, YaDeserialize)]
pub struct Control {
#[yaserde(attribute, rename = "name")]
pub named: String,
Expand All @@ -63,27 +63,27 @@ pub struct Control {
#[yaserde(attribute)]
pub color: String,
#[yaserde(attribute)]
pub scalef: f32,
pub scalef: Option<f32>,
#[yaserde(attribute)]
pub scalet: f32,
pub scalet: Option<f32>,
#[yaserde(attribute)]
pub local_off: bool,
pub local_off: Option<bool>,
#[yaserde(attribute)]
pub sp: bool,
pub sp: Option<bool>,
#[yaserde(attribute)]
pub sr: bool,
pub sr: Option<bool>,
pub midi: Vec<Midi>,
#[yaserde(attribute)]
pub response: String,
pub response: Option<String>,
#[yaserde(attribute)]
pub inverted: String,
pub inverted: Option<String>,
#[yaserde(attribute)]
pub centered: String,
pub centered: Option<String>,
#[yaserde(attribute)]
pub norollover: String,
pub norollover: Option<String>,
}

#[derive(Default, Debug, Clone, PartialEq, YaDeserialize)]
#[derive(Debug, Clone, PartialEq, YaDeserialize)]
pub struct Midi {
#[yaserde(attribute)]
pub var: String,
Expand Down
10 changes: 5 additions & 5 deletions examples/src/ln_dom.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// related to issue https://github.com/media-io/yaserde/issues/11
use yaserde::*;

#[derive(YaDeserialize, Default, Debug, PartialEq)]
#[derive(YaDeserialize, Debug, PartialEq)]
#[yaserde(root = "DOMSymbolItem")]
struct Level {
#[yaserde(attribute)]
Expand All @@ -11,13 +11,13 @@ struct Level {
timeline: Timeline,
}

#[derive(YaDeserialize, Default, Debug, PartialEq)]
#[derive(YaDeserialize, Debug, PartialEq)]
struct Timeline {
#[yaserde(rename = "DOMTimeline")]
timeline: DOMTimeline,
}

#[derive(YaDeserialize, Default, Debug, PartialEq)]
#[derive(YaDeserialize, Debug, PartialEq)]
struct DOMTimeline {
#[yaserde(attribute, rename = "name")]
named: String,
Expand All @@ -28,13 +28,13 @@ struct DOMTimeline {
layers: Layers,
}

#[derive(YaDeserialize, Default, Debug, PartialEq)]
#[derive(YaDeserialize, Debug, PartialEq)]
struct Layers {
#[yaserde(rename = "DOMLayer")]
dom_layer: Vec<DOMLayer>,
}

#[derive(YaDeserialize, Default, Debug, PartialEq)]
#[derive(YaDeserialize, Debug, PartialEq)]
struct DOMLayer {
#[yaserde(attribute, rename = "name")]
named: String,
Expand Down
12 changes: 6 additions & 6 deletions examples/src/svd.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use yaserde::YaSerialize;

#[derive(Default, PartialEq, Debug, YaSerialize)]
#[derive(PartialEq, Debug, YaSerialize)]
struct CpuDef {
#[yaserde(child)]
name: String,
Expand All @@ -18,7 +18,7 @@ struct CpuDef {
vendorsystickconfig: bool,
}

#[derive(Default, PartialEq, Debug, YaSerialize)]
#[derive(PartialEq, Debug, YaSerialize)]
struct Field {
name: String,
#[yaserde(child)]
Expand All @@ -29,7 +29,7 @@ struct Field {
access: String,
}

#[derive(Default, PartialEq, Debug, YaSerialize)]
#[derive(PartialEq, Debug, YaSerialize)]
struct Register {
#[yaserde(child)]
name: String,
Expand All @@ -49,7 +49,7 @@ struct Register {
fields: Vec<Field>,
}

#[derive(Default, PartialEq, Debug, YaSerialize)]
#[derive(PartialEq, Debug, YaSerialize)]
struct Peripheral {
#[yaserde(child)]
name: String,
Expand All @@ -69,7 +69,7 @@ struct Peripheral {
registers: Vec<Register>,
}

#[derive(Default, PartialEq, Debug, YaSerialize)]
#[derive(PartialEq, Debug, YaSerialize)]
struct DevAttrs {
#[yaserde(child)]
vendor: String,
Expand Down Expand Up @@ -103,7 +103,7 @@ struct DevAttrs {
peripherals: Vec<Peripheral>,
}

#[derive(Default, PartialEq, Debug, YaSerialize)]
#[derive(PartialEq, Debug, YaSerialize)]
#[yaserde(rename = "device")]
struct Device {
#[yaserde(attribute)]
Expand Down
4 changes: 2 additions & 2 deletions yaserde/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
//!```rust
//! use yaserde_derive::YaSerialize;
//!
//! #[derive(Default, PartialEq, Debug, YaSerialize)]
//! #[derive(PartialEq, Debug, YaSerialize)]
//! #[yaserde(rename = "device")]
//! struct Device {
//! #[yaserde(attribute)]
Expand All @@ -29,7 +29,7 @@
//! attributes: DeviceAttributes
//! }
//!
//! #[derive(Default, PartialEq, Debug, YaSerialize)]
//! #[derive(PartialEq, Debug, YaSerialize)]
//! struct DeviceAttributes {
//! #[yaserde(child)]
//! vendor: String,
Expand Down
2 changes: 1 addition & 1 deletion yaserde/tests/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ fn module_inclusion() {
init();

mod module {
#[derive(Debug, Default, PartialEq, YaDeserialize, YaSerialize)]
#[derive(Debug, PartialEq, YaDeserialize, YaSerialize)]
#[yaserde(rename = "module")]
pub struct Module {
#[yaserde(attribute)]
Expand Down
Loading

0 comments on commit 82df2e1

Please sign in to comment.