Advertisement
Guest User

Untitled

a guest
Jan 13th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 0.99 KB | None | 0 0
  1. impl<ViewT : LoginView> LoginPresenter<ViewT> {
  2.     pub fn register(&mut self, view: Box<ViewT>, service: Box<LoginService>) {
  3.         self._view = Some(view);
  4.         self._service = Some(service);
  5.         let callback = ||{
  6.                     self.login(&String::from("123"), &String::from("123"));
  7.                     };
  8.         match self._view {
  9.             Some(ref mut v) =>
  10.             {
  11.                 v.set_login_callback(callback);
  12.             },
  13.             _ =>  println!("Oh now"),
  14.         }
  15.     }
  16.    
  17.     fn login(&self, username: &String, password: &String) {
  18.         let user = User { name: username.clone(), password: password.clone() };
  19.         let mut is = false;
  20.         match se
  21.             Some(reflf._service { s) => is = s.login(&user),
  22.             _ =>  println!("Oh now"),
  23.         }
  24.         if !is {
  25.             match self._view {
  26.                 Some(ref v) => v.show_error(),
  27.                 _ =>  println!("Oh now"),
  28.             }
  29.         }
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement