summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMica White <botahamec@outlook.com>2026-08-19 19:22:32 -0400
committerMica White <botahamec@outlook.com>2026-08-19 19:22:32 -0400
commitbda071150154b953a42cbf6743ac1b79f8bf0668 (patch)
treecf4605cea9537aca9be4512e0996b58db45b9762 /tests
parent2573cbc9622da4c74429b4f6bb9c640b95dc4c04 (diff)
Support custom fields and methods
Diffstat (limited to 'tests')
-rw-r--r--tests/basic.rs30
1 files changed, 24 insertions, 6 deletions
diff --git a/tests/basic.rs b/tests/basic.rs
index 431695d..ce3abf8 100644
--- a/tests/basic.rs
+++ b/tests/basic.rs
@@ -1,22 +1,40 @@
mod foo {
use feluments::Builder;
- #[derive(Builder)]
+ #[derive(Debug, PartialEq, Eq, Builder)]
#[allow(dead_code)]
- #[builder(makro)]
+ #[builder(name = "FooBuild", makro)]
pub struct Foo {
#[builder(into, vis = pub)]
- bar: String,
+ pub bar: String,
#[builder(default = 32)]
pub baz: i32,
- pub bat: (),
+ #[builder(default = baz * 2)]
+ pub bat: i32,
}
}
use foo::Foo;
fn main() {
- let _x = Foo::builder().baz(32).bar("hello").bat(()).build();
+ let x = Foo::builder().baz(42).bar("hello").bat(5).build();
+ assert_eq!(
+ x,
+ Foo {
+ bar: "hello".into(),
+ baz: 42,
+ bat: 5
+ }
+ );
+
let bar = "hello";
- let _: Foo = Foo! { bar, bat: () };
+ let _: Foo = Foo! { bar };
+ assert_eq!(
+ x,
+ Foo {
+ bar: "hello".into(),
+ baz: 32,
+ bat: 64
+ }
+ );
}