File: no_type_leakage.rs

package info (click to toggle)
rust-typed-builder 0.20.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 188 kB
  • sloc: makefile: 4
file content (28 lines) | stat: -rw-r--r-- 511 bytes parent folder | download
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
26
27
28
// As long as this test compiles, it passes (test does not occur at runtime)

use typed_builder::TypedBuilder;

#[derive(PartialEq, TypedBuilder)]
#[builder(
    build_method(vis="pub", into=Bar),
    builder_method(vis=""),
    builder_type(vis="pub", name=BarBuilder),
)]
struct Foo {
    x: i32,
}

#[allow(unused)]
pub struct Bar(Foo);

impl Bar {
    pub fn builder() -> BarBuilder {
        Foo::builder()
    }
}

impl From<Foo> for Bar {
    fn from(wrapped: Foo) -> Self {
        Bar(wrapped)
    }
}