pub fn lookup_deck(conn: &PgConnection, user: &SerenityUser) -> Result<Option<Deck>> {
    use crate::schema::decks::dsl::*;
    let lg = match current_league(conn)? {
        Some(l) => l,
        None => return Ok(None),
    };

    let user = match lookup_user(conn, user) {
        Ok(user) => user,
        Err(err) => match err.downcast_ref::<DieselError>() {
            Some(DieselError::NotFound) => return Ok(None),
            Some(_other) => return Err(err),
            None => unreachable!(),
        },
    };
    decks
        .filter(owner.eq(user.id).and(league.eq(lg.id)).and(active.eq(true)))
        .get_result(conn)
        .optional()
        .map_err(|e| e.into())
}
/// Looks up the deck belonging to the given user from the current league.
Looks up the deck belonging to the given user from the current league.
Looks up the deck belonging to the given user from the current league .
pub fn lookup_deck(conn: &PgConnection, user: &SerenityUser) -> Result<Option<Deck>> {
    use crate::schema::decks::dsl::*;
    let lg = match current_league(conn)? {
        Some(l) => l,
        None => return Ok(None),
    };
    let user = match lookup_user(conn, user) {
        Ok(user) => user,
        Err(err) => match err.downcast_ref::<DieselError>() {
            Some(DieselError::NotFound) => return Ok(None),
            Some(_other) => return Err(err),
            None => unreachable!(),
        },
    };
    decks
        .filter(owner.eq(user.id).and(league.eq(lg.id)).and(active.eq(true)))
        .get_result(conn)
        .optional()
        .map_err(|e| e.into())
}
pub fn lookup_deck ( conn : & PgConnection , user : & SerenityUser ) -> Result < Option < Deck > > { use crate :: schema :: decks :: dsl :: * ; let lg = match current_league ( conn ) ? { Some ( l ) => l , None => return Ok ( None ) , } ; let user = match lookup_user ( conn , user ) { Ok ( user ) => user , Err ( err ) => match err . downcast_ref :: < DieselError > ( ) { Some ( DieselError :: NotFound ) => return Ok ( None ) , Some ( _other ) => return Err ( err ) , None => unreachable ! ( ) , } , } ; decks . filter ( owner . eq ( user . id ) . and ( league . eq ( lg . id ) ) . and ( active . eq ( true ) ) ) . get_result ( conn ) . optional ( ) . map_err ( | e | e . into ( ) ) }
Looks up the deck belonging to the given user from the current league.
Looks up the deck belonging to the given user from the current league .
conn
&PgConnection
user
&SerenityUser
conn
&PgConnection
user
&SerenityUser