base_message/
combination.rs1mod sealed {
9 pub trait Sealed {}
10}
11
12#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
14pub struct Singleton;
15
16#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
18pub struct List;
19
20#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
22pub struct Separate;
23
24pub trait Combination: sealed::Sealed {}
26
27impl sealed::Sealed for Singleton {}
28impl sealed::Sealed for List {}
29impl sealed::Sealed for Separate {}
30
31impl Combination for Singleton {}
32impl Combination for List {}
33impl Combination for Separate {}
34
35#[diagnostic::on_unimplemented(
37 message = "a field type that can repeat cannot be declared as `Option<T>` or `T`",
38 label = "instances of this field type combine into several values",
39 note = "declare a list or separate field as `Vec<T>`, so that every value is kept"
40)]
41pub trait SingleValue: Combination {}
42
43impl SingleValue for Singleton {}
44
45#[diagnostic::on_unimplemented(
47 message = "a singleton field type cannot be declared as `Vec<T>`",
48 label = "this field type appears at most once",
49 note = "declare a singleton field as `Option<T>`, or as `T` when it is required"
50)]
51pub trait MultipleValues: Combination {
52 const LIST: bool;
54}
55
56impl MultipleValues for List {
57 const LIST: bool = true;
58}
59
60impl MultipleValues for Separate {
61 const LIST: bool = false;
62}