mod sealed {
pub trait Sealed {}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct Singleton;
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct List;
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct Separate;
pub trait Combination: sealed::Sealed {}
impl sealed::Sealed for Singleton {}
impl sealed::Sealed for List {}
impl sealed::Sealed for Separate {}
impl Combination for Singleton {}
impl Combination for List {}
impl Combination for Separate {}
#[diagnostic::on_unimplemented(
message = "a field type that can repeat cannot be declared as `Option<T>` or `T`",
label = "instances of this field type combine into several values",
note = "declare a list or separate field as `Vec<T>`, so that every value is kept"
)]
pub trait SingleValue: Combination {}
impl SingleValue for Singleton {}
#[diagnostic::on_unimplemented(
message = "a singleton field type cannot be declared as `Vec<T>`",
label = "this field type appears at most once",
note = "declare a singleton field as `Option<T>`, or as `T` when it is required"
)]
pub trait MultipleValues: Combination {
const LIST: bool;
}
impl MultipleValues for List {
const LIST: bool = true;
}
impl MultipleValues for Separate {
const LIST: bool = false;
}