File: derive_trait.rs

package info (click to toggle)
rust-derive-builder 0.20.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 500 kB
  • sloc: makefile: 2
file content (25 lines) | stat: -rw-r--r-- 663 bytes parent folder | download | duplicates (15)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#![allow(dead_code)]

#[macro_use]
extern crate derive_builder;

#[derive(Debug, Default, Clone)]
struct NotPartialEq(String);

#[derive(Debug, Clone, Builder)]
#[builder(derive(Debug, PartialEq, Eq))]
struct Lorem {
    foo: u8,

    /// This type doesn't have `PartialEq` support, but that's fine
    /// since we don't want it in the builder.
    #[builder(setter(skip))]
    excluded: NotPartialEq,
}

#[test]
fn defaults() {
    // This macro requires that the two sides implement `PartialEq` AND `Debug`,
    // so this one line is testing that the requested traits were really generated.
    assert_eq!(LoremBuilder::default(), LoremBuilder::default());
}