From 378f21da89663bd498f24837d01fb5ed5b4b49f8 Mon Sep 17 00:00:00 2001 From: Tim Docker Date: Fri, 17 Mar 2023 17:01:47 +1100 Subject: [PATCH] Add Clone trait to rust standard types --- adl/stdlib/sys/types.adl-rs | 12 ++++++------ .../tests/test4/rs-output/test4/adl/test4.rs | 2 +- .../test6/rs-output/test6/adl/sys/adlast.rs | 16 ++++++++-------- .../tests/test6/rs-output/test6/adl/test6.rs | 2 +- rust/tests/src/test4/customtypes.rs | 4 ++-- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/adl/stdlib/sys/types.adl-rs b/adl/stdlib/sys/types.adl-rs index a0cf784e..a76e0cf4 100644 --- a/adl/stdlib/sys/types.adl-rs +++ b/adl/stdlib/sys/types.adl-rs @@ -5,36 +5,36 @@ import adlc.config.rust.*; annotation Maybe RustCustomType { "rustname" : "{{STDLIBMODULE}}::custom::sys::types::maybe::Maybe", "helpers" : "{{STDLIBMODULE}}::custom::sys::types::maybe::Maybe", - "stdTraits": ["Eq", "PartialEq", "Hash", "Serialize", "Deserialize"] + "stdTraits": ["Eq", "PartialEq", "Hash", "Serialize", "Deserialize", "Clone"] }; annotation MapEntry RustCustomType { "rustname" : "{{STDLIBMODULE}}::custom::sys::types::mapentry::MapEntry", "helpers" : "{{STDLIBMODULE}}::custom::sys::types::mapentry::MapEntry", - "stdTraits": ["Eq", "PartialEq", "Hash", "Serialize", "Deserialize"] + "stdTraits": ["Eq", "PartialEq", "Hash", "Serialize", "Deserialize", "Clone"] }; annotation Map RustCustomType { "rustname" : "{{STDLIBMODULE}}::custom::sys::types::map::Map", "helpers" : "{{STDLIBMODULE}}::custom::sys::types::map::Map", - "stdTraits": ["Eq", "PartialEq", "Serialize", "Deserialize"] + "stdTraits": ["Eq", "PartialEq", "Serialize", "Deserialize", "Clone"] }; annotation Set RustCustomType { "rustname" : "{{STDLIBMODULE}}::custom::sys::types::set::Set", "helpers" : "{{STDLIBMODULE}}::custom::sys::types::set::Set", - "stdTraits": ["Eq", "PartialEq", "Serialize", "Deserialize"] + "stdTraits": ["Eq", "PartialEq", "Serialize", "Deserialize", "Clone"] }; annotation Pair RustCustomType { "rustname" : "{{STDLIBMODULE}}::custom::sys::types::pair::Pair", "helpers" : "{{STDLIBMODULE}}::custom::sys::types::pair::Pair", - "stdTraits": ["Eq", "PartialEq", "Hash", "Serialize", "Deserialize"] + "stdTraits": ["Eq", "PartialEq", "Hash", "Serialize", "Deserialize", "Clone"] }; annotation Result RustCustomType { "rustname" : "{{STDLIBMODULE}}::custom::sys::types::result::Result", "helpers" : "{{STDLIBMODULE}}::custom::sys::types::result::Result", - "stdTraits": ["Eq", "PartialEq", "Hash", "Serialize", "Deserialize"] + "stdTraits": ["Eq", "PartialEq", "Hash", "Serialize", "Deserialize", "Clone"] }; }; diff --git a/haskell/compiler/tests/test4/rs-output/test4/adl/test4.rs b/haskell/compiler/tests/test4/rs-output/test4/adl/test4.rs index f69e768d..1d80f7b5 100644 --- a/haskell/compiler/tests/test4/rs-output/test4/adl/test4.rs +++ b/haskell/compiler/tests/test4/rs-output/test4/adl/test4.rs @@ -31,7 +31,7 @@ impl CDate0 { } } -#[derive(Deserialize,Eq,PartialEq,Serialize)] +#[derive(Clone,Deserialize,Eq,PartialEq,Serialize)] pub struct S { #[serde(rename="v1")] pub v_1: Date, diff --git a/haskell/compiler/tests/test6/rs-output/test6/adl/sys/adlast.rs b/haskell/compiler/tests/test6/rs-output/test6/adl/sys/adlast.rs index a8f7620c..8dfa387a 100644 --- a/haskell/compiler/tests/test6/rs-output/test6/adl/sys/adlast.rs +++ b/haskell/compiler/tests/test6/rs-output/test6/adl/sys/adlast.rs @@ -57,7 +57,7 @@ impl TypeExpr { } } -#[derive(Deserialize,PartialEq,Serialize)] +#[derive(Clone,Deserialize,PartialEq,Serialize)] pub struct Field { pub name: Ident, @@ -84,7 +84,7 @@ impl Field { } } -#[derive(Deserialize,PartialEq,Serialize)] +#[derive(Clone,Deserialize,PartialEq,Serialize)] pub struct Struct { #[serde(rename="typeParams")] pub type_params: Vec, @@ -101,7 +101,7 @@ impl Struct { } } -#[derive(Deserialize,PartialEq,Serialize)] +#[derive(Clone,Deserialize,PartialEq,Serialize)] pub struct Union { #[serde(rename="typeParams")] pub type_params: Vec, @@ -136,7 +136,7 @@ impl TypeDef { } } -#[derive(Deserialize,PartialEq,Serialize)] +#[derive(Clone,Deserialize,PartialEq,Serialize)] pub struct NewType { #[serde(rename="typeParams")] pub type_params: Vec, @@ -157,7 +157,7 @@ impl NewType { } } -#[derive(Deserialize,PartialEq,Serialize)] +#[derive(Clone,Deserialize,PartialEq,Serialize)] pub enum DeclType { #[serde(rename="struct_")] Struct(Struct), @@ -172,7 +172,7 @@ pub enum DeclType { Newtype(NewType), } -#[derive(Deserialize,PartialEq,Serialize)] +#[derive(Clone,Deserialize,PartialEq,Serialize)] pub struct Decl { pub name: Ident, @@ -195,7 +195,7 @@ impl Decl { } } -#[derive(Deserialize,PartialEq,Serialize)] +#[derive(Clone,Deserialize,PartialEq,Serialize)] pub struct ScopedDecl { #[serde(rename="moduleName")] pub module_name: ModuleName, @@ -223,7 +223,7 @@ pub enum Import { ScopedName(ScopedName), } -#[derive(Deserialize,PartialEq,Serialize)] +#[derive(Clone,Deserialize,PartialEq,Serialize)] pub struct Module { pub name: ModuleName, diff --git a/haskell/compiler/tests/test6/rs-output/test6/adl/test6.rs b/haskell/compiler/tests/test6/rs-output/test6/adl/test6.rs index 8884731f..20538d39 100644 --- a/haskell/compiler/tests/test6/rs-output/test6/adl/test6.rs +++ b/haskell/compiler/tests/test6/rs-output/test6/adl/test6.rs @@ -8,7 +8,7 @@ use crate::test6::adl::sys::types::Either; use serde::Deserialize; use serde::Serialize; -#[derive(Deserialize,PartialEq,Serialize)] +#[derive(Clone,Deserialize,PartialEq,Serialize)] pub struct S { pub f_pair: Pair, diff --git a/rust/tests/src/test4/customtypes.rs b/rust/tests/src/test4/customtypes.rs index 30eb70c5..4f2b47c7 100644 --- a/rust/tests/src/test4/customtypes.rs +++ b/rust/tests/src/test4/customtypes.rs @@ -7,7 +7,7 @@ use std::result; use crate::test4::adl::test4::CDate0; -#[derive(Eq, PartialEq, Hash)] +#[derive(Eq, PartialEq, Hash, Clone)] pub struct Date(NaiveDate); impl Serialize for Date { @@ -38,7 +38,7 @@ pub mod datehelpers { } } -#[derive(Eq, PartialEq, Hash)] +#[derive(Eq, PartialEq, Hash, Clone)] pub struct CDate(NaiveDate); impl Serialize for CDate {