Skip to content

Instantly share code, notes, and snippets.

@FermiDirak
Last active January 16, 2022 08:03
Show Gist options
  • Save FermiDirak/9cf2c87ed6b43f559a43da54d708fd0c to your computer and use it in GitHub Desktop.
Save FermiDirak/9cf2c87ed6b43f559a43da54d708fd0c to your computer and use it in GitHub Desktop.
// user_model.rs
struct UserModel { /* ... */ }
impl UserModel {
pub fn fullname() -> String;
// ...
}
// happy_birthday_service.rs
pub fn send_message(session_context: &SessionContext, /* ... */) {
let message = session_context.user.happy_birthday_message();
send_email(sesson_context.user.email, message);
}
impl UserModel {
pub fn happy_birthday_message(&self) -> String {
format!("Happy birthday, {} 🎉", self.fullname());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment