use structural_typing::{presence::Present, structural};
#[structural]
struct User {
name: String,
email: String,
}
impl<F: user::Fields<name = Present>> User<F> {
fn greet(&self) -> String {
format!("Hello, {}!", self.name)
}
}
fn main() {
let user = User::empty().name("Alice".to_owned());
assert_eq!(user.greet(), "Hello, Alice!");
let user = user.email("alice@example.com".to_owned());
assert_eq!(user.email, "alice@example.com");
}