bon_sandbox/attr_setters_doc_default_skip.rs
1//! Showcases the docs output with `setters(doc(default(skip)))` attribute.
2//!
3//! There are two examples of the usage of this attribute at different levels.
4//! Follow the `Source` links of every example to see how the attributes are used.
5//!
6//! Examples:
7//! - [`MemberExampleBuilder`] - usage of the attribute on an individual member
8//! - [`TopLevelExampleBuilder`] - usage of the attribute on the top level for all members
9
10#[derive(bon::Builder)]
11pub struct MemberExample {
12 /// Shows the default (no overrides).
13 #[builder(default = 42)]
14 shown: u32,
15
16 /// Skips the default (overridden via the attribute).
17 #[builder(default = 42, setters(doc(default(skip))))]
18 hidden: u32,
19}
20
21#[derive(bon::Builder)]
22#[builder(on(u32, setters(doc(default(skip)))))]
23pub struct TopLevelExample {
24 /// Doesn't match the `on(u32, ...)` type pattern, and thus shows
25 /// the default in the docs.
26 /// If you want to select all members, then use the pattern `_`.
27 #[builder(default = 42)]
28 shown: i32,
29
30 /// Matches the `on(u32, ...)` type pattern, and thus skips the default
31 /// in the docs.
32 #[builder(default = 42)]
33 hidden: u32,
34}