Skip to content

Commit d476e85

Browse files
Merge pull request #167 from patrickelectric/clone
Add clone do types and generated code
2 parents 03328f5 + 075f6b0 commit d476e85

File tree

40 files changed

+70
-69
lines changed

40 files changed

+70
-69
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ There are cases when schema allows extensions for the certain type.
9797
In such cases we don't know in advance what fields must be present in Rust struct so we don't add them to output:
9898

9999
```rust
100-
#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]
100+
#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)]
101101
#[yaserde(prefix = "tns", namespace = "tns: http://example.com")]
102102
pub struct MyType {
103103
#[yaserde(prefix = "tns", rename = "Parameters")]

wsdl-parser/tests/port_type_to_function/expected.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]
2+
#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)]
33
#[yaserde(prefix = "tds", namespace = "tds: http://www.onvif.org/ver10/device/wsdl")]
44
pub struct GetServices {
55
// Indicates if the service capabilities (untyped) should be included in the
@@ -11,7 +11,7 @@ pub struct GetServices {
1111
impl Validate for GetServices {}
1212

1313

14-
#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]
14+
#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)]
1515
#[yaserde(prefix = "tds", namespace = "tds: http://www.onvif.org/ver10/device/wsdl")]
1616
pub struct GetServicesResponse {
1717
// Each Service element contains information about one service.

xsd-parser/src/generator/enum.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ pub trait EnumGenerator {
6565
return "#[derive(PartialEq, Debug, UtilsUnionSerDe)]".into();
6666
}
6767

68-
let derives = "#[derive(PartialEq, Debug, YaSerialize, YaDeserialize)]";
68+
let derives = "#[derive(PartialEq, Debug, Clone, YaSerialize, YaDeserialize)]";
6969
let tns = gen.target_ns.borrow();
7070
match tns.as_ref() {
7171
Some(tn) => match tn.name() {

xsd-parser/src/generator/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ mod test {
9292
..Default::default()
9393
}));
9494
let comment = "// comment\n";
95-
let macros = "#[derive(Default, PartialEq, Debug, UtilsTupleIo, UtilsDefaultSerde)]\n";
95+
let macros =
96+
"#[derive(Default, Clone, PartialEq, Debug, UtilsTupleIo, UtilsDefaultSerde)]\n";
9697
let validation = "impl Validate for Name {}\n";
9798
let expected =
9899
format!("{}{}pub struct Name (pub Type);\n\n{}", comment, macros, validation);

xsd-parser/src/generator/struct.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ pub trait StructGenerator {
7979
}
8080

8181
fn macros(&self, _entity: &Struct, gen: &Generator) -> Cow<'static, str> {
82-
let derives = "#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]\n";
82+
let derives = "#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)]\n";
8383
let tns = gen.target_ns.borrow();
8484
match tns.as_ref() {
8585
Some(tn) => match tn.name() {

xsd-parser/src/generator/tuple_struct.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub trait TupleStructGenerator {
3939
}
4040

4141
fn macros(&self, _entity: &TupleStruct, _gen: &Generator) -> Cow<'static, str> {
42-
"#[derive(Default, PartialEq, Debug, UtilsTupleIo, UtilsDefaultSerde)]\n".into()
42+
"#[derive(Default, Clone, PartialEq, Debug, UtilsTupleIo, UtilsDefaultSerde)]\n".into()
4343
}
4444

4545
fn format_comment(&self, entity: &TupleStruct, gen: &Generator) -> String {

xsd-parser/tests/all/expected.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]
1+
#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)]
22
#[yaserde(prefix = "tns", namespace = "tns: http://example.com")]
33
pub struct FooType {
44
#[yaserde(prefix = "tns", rename = "Once")]

xsd-parser/tests/any/expected.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]
1+
#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)]
22
#[yaserde(prefix = "tns", namespace = "tns: http://example.com")]
33
pub struct FooType {
44
#[yaserde(prefix = "tns", rename = "Name")]

xsd-parser/tests/choice/expected.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
#[derive(Default, PartialEq, Debug, UtilsTupleIo, UtilsDefaultSerde)]
1+
#[derive(Default, Clone, PartialEq, Debug, UtilsTupleIo, UtilsDefaultSerde)]
22
pub struct BarType(pub String);
33

4-
#[derive(Default, PartialEq, Debug, UtilsTupleIo, UtilsDefaultSerde)]
4+
#[derive(Default, Clone, PartialEq, Debug, UtilsTupleIo, UtilsDefaultSerde)]
55
pub struct BazType(pub i32);
66

7-
#[derive(PartialEq, Debug, YaSerialize, YaDeserialize)]
7+
#[derive(PartialEq, Debug, Clone, YaSerialize, YaDeserialize)]
88
#[yaserde(prefix = "tns", namespace = "tns: http://example.com")]
99
pub enum FooTypeChoice {
1010
Bar(BarType),
@@ -18,7 +18,7 @@ impl Default for FooTypeChoice {
1818
}
1919
}
2020

21-
#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]
21+
#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)]
2222
#[yaserde(prefix = "tns", namespace = "tns: http://example.com")]
2323
pub struct FooType {
2424
#[yaserde(flatten)]

xsd-parser/tests/complex_type/expected.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]
1+
#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)]
22
#[yaserde(prefix = "tns", namespace = "tns: http://example.com")]
33
pub struct FooType {
44
#[yaserde(prefix = "tns", rename = "Min")]

0 commit comments

Comments
 (0)