Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct Connection;
- struct Pool
- {
- connection: Connection,
- }
- impl Pool {
- fn new () -> Pool
- {
- Pool {
- connection: Connection{},
- }
- }
- fn connection(&self) -> &Connection
- {
- &self.connection
- }
- }
- struct Model<'a>
- {
- connection: &'a Connection,
- }
- impl<'a> Model<'a>
- {
- fn new(pool: &Pool) -> Model<'a>
- {
- Model {
- connection: pool.connection()
- }
- }
- }
- fn main() {
- let pool = Pool::new();
- let model1 = Model::new(&pool);
- let model2 = Model::new(&pool);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement