Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. struct Connection;
  2.  
  3. struct Pool
  4. {
  5. connection: Connection,
  6. }
  7.  
  8. impl Pool {
  9. fn new () -> Pool
  10. {
  11. Pool {
  12. connection: Connection{},
  13. }
  14. }
  15.  
  16. fn connection(&self) -> &Connection
  17. {
  18. &self.connection
  19. }
  20. }
  21.  
  22. struct Model<'a>
  23. {
  24. connection: &'a Connection,
  25. }
  26.  
  27. impl<'a> Model<'a>
  28. {
  29. fn new(pool: &Pool) -> Model<'a>
  30. {
  31. Model {
  32. connection: pool.connection()
  33. }
  34. }
  35. }
  36.  
  37. fn main() {
  38. let pool = Pool::new();
  39. let model1 = Model::new(&pool);
  40. let model2 = Model::new(&pool);
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement