bon_sandbox/missing_docs_test.rs
1//! This is based on the issue <https://github.com/elastio/bon/issues/38>
2#![warn(missing_docs)]
3
4use bon::{bon, builder, Builder};
5
6/// [`MyStruct`] docs
7pub struct MyStruct;
8
9#[bon::bon]
10impl MyStruct {
11 /// [`MyStruct::builder()`] docs
12 #[builder]
13 pub fn new() -> Self {
14 eprintln!("Non-const");
15 Self
16 }
17}
18
19/// [`function`] docs
20#[builder]
21pub fn function(
22 // Docs on setters for function parameters are autogenerated
23 // So missing docs here shouldn't be reported
24 _arg1: u32,
25 _arg2: bool,
26) {
27 eprintln!("Non-const");
28}
29
30/// [`Struct`] docs
31#[derive(Builder)]
32pub struct Struct {
33 // Docs on setters for struct fields are autogenerated
34 // So missing docs here shouldn't be reported
35 _field1: String,
36 _field2: usize,
37}
38
39#[bon]
40impl Struct {
41 /// [`Struct::method()`] docs
42 #[builder]
43 pub fn method(&self, _arg1: u32, _arg2: bool) {
44 eprintln!("Non-const");
45 let _ = self;
46 }
47}
48
49/// [`GenericStruct`] docs
50#[derive(bon::Builder)]
51pub struct GenericStruct<T> {
52 // Docs on setters for struct fields are autogenerated
53 // So missing docs here shouldn't be reported
54 _field: T,
55}