Skip to content

Instantly share code, notes, and snippets.

@CorvusEtiam
Created September 27, 2018 16:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CorvusEtiam/32ec5bc84d2e8db53f6a7764059cc806 to your computer and use it in GitHub Desktop.
Save CorvusEtiam/32ec5bc84d2e8db53f6a7764059cc806 to your computer and use it in GitHub Desktop.
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