Skip to content

Commit

Permalink
Add Clone trait to rust standard types
Browse files Browse the repository at this point in the history
  • Loading branch information
timbod7 committed Mar 17, 2023
1 parent 43ebf2d commit 378f21d
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
12 changes: 6 additions & 6 deletions adl/stdlib/sys/types.adl-rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
};
};
2 changes: 1 addition & 1 deletion haskell/compiler/tests/test4/rs-output/test4/adl/test4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
16 changes: 8 additions & 8 deletions haskell/compiler/tests/test6/rs-output/test6/adl/sys/adlast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl TypeExpr {
}
}

#[derive(Deserialize,PartialEq,Serialize)]
#[derive(Clone,Deserialize,PartialEq,Serialize)]
pub struct Field {
pub name: Ident,

Expand All @@ -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<Ident>,
Expand All @@ -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<Ident>,
Expand Down Expand Up @@ -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<Ident>,
Expand All @@ -157,7 +157,7 @@ impl NewType {
}
}

#[derive(Deserialize,PartialEq,Serialize)]
#[derive(Clone,Deserialize,PartialEq,Serialize)]
pub enum DeclType {
#[serde(rename="struct_")]
Struct(Struct),
Expand All @@ -172,7 +172,7 @@ pub enum DeclType {
Newtype(NewType),
}

#[derive(Deserialize,PartialEq,Serialize)]
#[derive(Clone,Deserialize,PartialEq,Serialize)]
pub struct Decl {
pub name: Ident,

Expand All @@ -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,
Expand Down Expand Up @@ -223,7 +223,7 @@ pub enum Import {
ScopedName(ScopedName),
}

#[derive(Deserialize,PartialEq,Serialize)]
#[derive(Clone,Deserialize,PartialEq,Serialize)]
pub struct Module {
pub name: ModuleName,

Expand Down
2 changes: 1 addition & 1 deletion haskell/compiler/tests/test6/rs-output/test6/adl/test6.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<i32, f64>,

Expand Down
4 changes: 2 additions & 2 deletions rust/tests/src/test4/customtypes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -38,7 +38,7 @@ pub mod datehelpers {
}
}

#[derive(Eq, PartialEq, Hash)]
#[derive(Eq, PartialEq, Hash, Clone)]
pub struct CDate(NaiveDate);

impl Serialize for CDate {
Expand Down

0 comments on commit 378f21d

Please sign in to comment.