iron / persistent

Middleware for sharing data between requests
43 stars 29 forks source link

Issue when impl Trait Key #54

Closed inxi-pc closed 8 years ago

inxi-pc commented 8 years ago

Hi,

I have a issue when i impl Key trait in Struct that include Arcr2d2::Pool type field. could you help me sort out the issue? Thanks!

// This is struct 
pub struct App {
    pool: Arc<r2d2::Pool<PostgresConnectionManager>>,
}
src/main.rs:63:5: 63:53 error: the trait bound `r2d2_postgres::PostgresConnectionManager: r2d2::ManageConnection` is not satisfied [E0277]
src/main.rs:63     pool: Arc<r2d2::Pool<PostgresConnectionManager>>,
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/main.rs:63:5: 63:53 help: run `rustc --explain E0277` to see a detailed explanation
src/main.rs:63:5: 63:53 note: required by `r2d2::Pool`
src/main.rs:66:6: 66:9 error: the trait bound `r2d2_postgres::PostgresConnectionManager: r2d2::ManageConnection` is not satisfied [E0277]
src/main.rs:66 impl Key for App { type Value = App; }
                    ^~~
src/main.rs:66:6: 66:9 help: run `rustc --explain E0277` to see a detailed explanation
src/main.rs:66:6: 66:9 note: required because of the requirements on the impl of `std::marker::Reflect` for `alloc::arc::ArcInner<r2d2::SharedPool<r2d2_postgres::PostgresConnectionManager>>`
src/main.rs:66:6: 66:9 note: required because of the requirements on the impl of `std::marker::Reflect` for `std::marker::PhantomData<alloc::arc::ArcInner<r2d2::SharedPool<r2d2_postgres::PostgresConnectionManager>>>`
src/main.rs:66:6: 66:9 note: required because of the requirements on the impl of `std::marker::Reflect` for `std::ptr::Shared<alloc::arc::ArcInner<r2d2::SharedPool<r2d2_postgres::PostgresConnectionManager>>>`
src/main.rs:66:6: 66:9 note: required because of the requirements on the impl of `std::marker::Reflect` for `std::sync::Arc<r2d2::SharedPool<r2d2_postgres::PostgresConnectionManager>>`
src/main.rs:66:6: 66:9 note: required because of the requirements on the impl of `std::marker::Reflect` for `r2d2::Pool<r2d2_postgres::PostgresConnectionManager>`
src/main.rs:66:6: 66:9 note: required because of the requirements on the impl of `std::marker::Reflect` for `alloc::arc::ArcInner<r2d2::Pool<r2d2_postgres::PostgresConnectionManager>>`
src/main.rs:66:6: 66:9 note: required because of the requirements on the impl of `std::marker::Reflect` for `std::marker::PhantomData<alloc::arc::ArcInner<r2d2::Pool<r2d2_postgres::PostgresConnectionManager>>>`
src/main.rs:66:6: 66:9 note: required because of the requirements on the impl of `std::marker::Reflect` for `std::ptr::Shared<alloc::arc::ArcInner<r2d2::Pool<r2d2_postgres::PostgresConnectionManager>>>`
src/main.rs:66:6: 66:9 note: required because of the requirements on the impl of `std::marker::Reflect` for `std::sync::Arc<r2d2::Pool<r2d2_postgres::PostgresConnectionManager>>`
src/main.rs:66:6: 66:9 note: required because of the requirements on the impl of `std::marker::Reflect` for `App`
src/main.rs:66:6: 66:9 note: required by `iron::typemap::Key`
src/main.rs:89:5: 91:6 error: the trait bound `r2d2_postgres::PostgresConnectionManager: r2d2::ManageConnection` is not satisfied [E0277]
src/main.rs:89     pub fn conn(&self) -> Result<Connection, Error> {
src/main.rs:90         Ok(try!(self.pool.get()))
src/main.rs:91     }
src/main.rs:89:5: 91:6 help: run `rustc --explain E0277` to see a detailed explanation
src/main.rs:89:5: 91:6 note: required by `r2d2::PooledConnection`