From 4cb3884e24b3cba3347ff93475bbabd6fe18d2fa Mon Sep 17 00:00:00 2001 From: HampusM Date: Fri, 22 Jul 2022 13:25:45 +0200 Subject: refactor: make factories an optional feature --- examples/factory/user.rs | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 examples/factory/user.rs (limited to 'examples/factory/user.rs') diff --git a/examples/factory/user.rs b/examples/factory/user.rs new file mode 100644 index 0000000..121ad25 --- /dev/null +++ b/examples/factory/user.rs @@ -0,0 +1,42 @@ +use crate::interfaces::user::IUser; + +pub struct User +{ + name: &'static str, + date_of_birth: &'static str, + password: &'static str, +} + +impl User +{ + pub fn new( + name: &'static str, + date_of_birth: &'static str, + password: &'static str, + ) -> Self + { + Self { + name, + date_of_birth, + password, + } + } +} + +impl IUser for User +{ + fn get_name(&self) -> &'static str + { + self.name.clone() + } + + fn get_date_of_birth(&self) -> &'static str + { + self.date_of_birth.clone() + } + + fn get_password(&self) -> &'static str + { + self.password.clone() + } +} -- cgit v1.2.3-18-g5258