bon/builder_state.rs
1//! The items here are intentionally defined in a private module not inside of the
2//! [`crate::__`] module. This is because that module is marked with `#[deprecated]`
3//! which makes all items defined in that module also deprecated.
4//!
5//! This is not the desired behavior for the items defined here. They are not deprecated,
6//! and they are expected to be exposed to the users. However, the users must not reference
7//! them through the `bon` crate. Instead, they should use the re-exports from the state
8//! module generated for the builder.
9
10use crate::__::{Sealed, Set, Unset};
11
12/// Marker trait that indicates that the member is set, i.e. at least
13/// one of its setters was called.
14#[rustversion::attr(
15 since(1.78.0),
16 diagnostic::on_unimplemented(
17 message = "the member `{Self}` was not set, but this method requires it to be set",
18 label = "the member `{Self}` was not set, but this method requires it to be set"
19 )
20)]
21pub trait IsSet: Sealed {}
22
23/// Marker trait that indicates that the member is unset, i.e. none
24/// of its setters was called.
25#[rustversion::attr(
26 since(1.78.0),
27 diagnostic::on_unimplemented(
28 message = "the member `{Self}` was already set, but this method requires it to be unset",
29 label = "the member `{Self}` was already set, but this method requires it to be unset"
30 )
31)]
32pub trait IsUnset: Sealed {}
33
34#[doc(hidden)]
35impl<Name> IsSet for Set<Name> {}
36
37#[doc(hidden)]
38impl<Name> IsUnset for Unset<Name> {}