- 
                Notifications
    You must be signed in to change notification settings 
- Fork 30
Open
Description
Could you provide an example that uses a Trait? Or do you know a repository where I can find code examples?
Here is what I'd like to do:
extern crate iron;
extern crate mount;
extern crate persistent;
use std::io;
use iron::prelude::*;
use iron::typemap::Key;
use persistent::State;
use mount::Mount;
struct X;
trait Db {
    fn get(&mut self, id: &str) -> Result<X, io::Error>; 
}
struct Server {
    chain: Chain
}
fn create_server<D: Db + Key>(db: D) -> Server {
    let mount = Mount::new();
    let chain = Chain::new(mount);
    chain.link(State::<D>::both(db));
    Server {
        chain: chain
    }
}
struct Store; 
impl Db for Store {
    fn get(&mut self, id: &str) -> Result<X, io::Error> {
        Ok(X{})
    } 
}
impl Key for Store {
    type Value = Store;
}
fn main() {
    let store = Store {};
    let s = create_server(store);
}edit: renamed issue & changed content
Metadata
Metadata
Assignees
Labels
No labels