Created
September 27, 2018 16:07
-
-
Save CorvusEtiam/32ec5bc84d2e8db53f6a7764059cc806 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub struct Inserter; | |
pub struct Controller { | |
pub inserter : Inserter, | |
pub conn: Connection | |
} | |
pub struct ConnectedInserter<'a> { | |
conn: &'a SqliteConnection, | |
} | |
impl ConnectedInserter { | |
pub fn insert_smth() {} | |
} | |
impl Inserter { | |
pub fn new() -> Inserter { | |
Inserter {} | |
} | |
pub fn with(&self, connect : &Connection ) -> ConnectedInserter { | |
ConnectedInserter { | |
conn: connect | |
} | |
} | |
} | |
impl Controller { | |
pub fn use() { | |
self.inserter.with(self.conn).insert_something(); | |
} | |
} | |
fn main() { | |
let control = Controller { inserter : Inserter {}, conn : Connection::new() }; | |
control.use(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment