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:
externcrate iron;externcrate mount;externcrate persistent;use std::io;use iron::prelude::*;use iron::typemap::Key;use persistent::State;use mount::Mount;structX;traitDb{fnget(&mutself,id:&str) -> Result<X, io::Error>;}structServer{chain:Chain}fncreate_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
}}structStore;implDbforStore{fnget(&mutself,id:&str) -> Result<X, io::Error>{Ok(X{})}}implKeyforStore{typeValue = Store;}fnmain(){let store = Store{};let s = create_server(store);}edit: renamed issue & changed content
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:
edit: renamed issue & changed content