diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-07 05:48:48 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-07 05:48:48 +0000 |
commit | ef24de24a82fe681581cc130f342363c47c0969a (patch) | |
tree | 0d494f7e1a38b95c92426f58fe6eaa877303a86c /vendor/zerovec-derive/examples/make_var.rs | |
parent | Releasing progress-linux version 1.74.1+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-ef24de24a82fe681581cc130f342363c47c0969a.tar.xz rustc-ef24de24a82fe681581cc130f342363c47c0969a.zip |
Merging upstream version 1.75.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/zerovec-derive/examples/make_var.rs')
-rw-r--r-- | vendor/zerovec-derive/examples/make_var.rs | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/vendor/zerovec-derive/examples/make_var.rs b/vendor/zerovec-derive/examples/make_var.rs index 7dedfd3e9..47e1418cd 100644 --- a/vendor/zerovec-derive/examples/make_var.rs +++ b/vendor/zerovec-derive/examples/make_var.rs @@ -59,6 +59,30 @@ struct MultiFieldStruct<'a> { f: char, } +#[make_varule(MultiFieldConsecutiveStructULE)] +#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Debug, serde::Serialize, serde::Deserialize)] +#[zerovec::derive(Serialize, Deserialize, Debug)] +struct MultiFieldConsecutiveStruct<'a> { + #[serde(borrow)] + a: Cow<'a, str>, + #[serde(borrow)] + b: Cow<'a, str>, + #[serde(borrow)] + c: Cow<'a, str>, + #[serde(borrow)] + d: Cow<'a, str>, +} + +#[make_varule(CustomVarFieldULE)] +#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Debug, serde::Serialize, serde::Deserialize)] +#[zerovec::derive(Serialize, Deserialize, Debug)] +struct CustomVarField<'a> { + #[zerovec::varule(MultiFieldStructULE)] + #[serde(borrow)] + a: MultiFieldStruct<'a>, + b: u32, +} + #[make_varule(MultiFieldTupleULE)] #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Debug, serde::Serialize, serde::Deserialize)] #[zerovec::derive(Serialize, Deserialize, Debug)] @@ -129,6 +153,11 @@ fn main() { assert_eq!(stack, &MultiFieldStruct::zero_from(zero)) }); + assert_zerovec::<MultiFieldConsecutiveStructULE, MultiFieldConsecutiveStruct, _>( + TEST_MULTICONSECUTIVE, + |stack, zero| assert_eq!(stack, &MultiFieldConsecutiveStruct::zero_from(zero)), + ); + let vartuples = &[ VarTupleStruct(101, 'ø', TEST_STRINGS1.into()), VarTupleStruct(9499, '⸘', TEST_STRINGS2.into()), @@ -187,3 +216,11 @@ const TEST_MULTIFIELD: &[MultiFieldStruct<'static>] = &[ f: 'ə', }, ]; + +const TEST_MULTICONSECUTIVE: &[MultiFieldConsecutiveStruct<'static>] = + &[MultiFieldConsecutiveStruct { + a: Cow::Borrowed("one"), + b: Cow::Borrowed("2"), + c: Cow::Borrowed("three"), + d: Cow::Borrowed("four"), + }]; |