Guest User

Untitled

a guest
Apr 4th, 2019
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. enum Error {
  2. InvalidLoginOrPassword,
  3. Other,
  4. }
  5.  
  6. struct Status {
  7. code: i32
  8. }
  9.  
  10. impl Status {
  11. fn ok() -> Status {
  12. Status {
  13. code: 200,
  14. }
  15. }
  16. }
  17.  
  18. struct LoginForm(Status);
  19. struct UpdateUserForm(Status);
  20. // etc...
  21.  
  22. fn login<'a>(_username: &'a str, _password: &'a str) -> Result<LoginForm, Error> {
  23. Ok(LoginForm(Status::ok()))
  24. }
  25.  
  26. fn main() {
  27. login("Username", "Password");
  28. }
Add Comment
Please, Sign In to add comment