pub fn versions(req: &mut dyn Request) -> AppResult<Response> {
    let crate_name = &req.params()["crate_id"];
    let conn = req.db_read_only()?;
    let krate = Crate::by_name(crate_name).first::<Crate>(&*conn)?;
    let mut versions_and_publishers: Vec<(Version, Option<User>)> = krate
        .all_versions()
        .left_outer_join(users::table)
        .select((versions::all_columns, users::all_columns.nullable()))
        .load(&*conn)?;
    versions_and_publishers.sort_by(|a, b| b.0.num.cmp(&a.0.num));
    let versions = versions_and_publishers
        .iter()
        .map(|(v, _)| v)
        .cloned()
        .collect::<Vec<_>>();
    let versions = versions_and_publishers
        .into_iter()
        .zip(VersionOwnerAction::for_versions(&conn, &versions)?.into_iter())
        .map(|((v, pb), aas)| v.encodable(crate_name, pb, aas))
        .collect();

    #[derive(Serialize)]
    struct R {
        versions: Vec<EncodableVersion>,
    }
    Ok(req.json(&R { versions }))
}
/// Handles the `GET /crates/:crate_id/versions` route.
// FIXME: Not sure why this is necessary since /crates/:crate_id returns
// this information already, but ember is definitely requesting it
Handles the `GET /crates/:crate_id/versions` route.
FIXME: Not sure why this is necessary since /crates/:crate_id returns
this information already, but ember is definitely requesting it
Handles the ` GET / crates / : crate_id / versions ` route . FIXME : Not sure why this is necessary since / crates / : crate_id returns this information already but ember is definitely requesting it
pub fn versions(req: &mut dyn Request) -> AppResult<Response> {
    let crate_name = &req.params()["crate_id"];
    let conn = req.db_read_only()?;
    let krate = Crate::by_name(crate_name).first::<Crate>(&*conn)?;
    let mut versions_and_publishers: Vec<(Version, Option<User>)> = krate
        .all_versions()
        .left_outer_join(users::table)
        .select((versions::all_columns, users::all_columns.nullable()))
        .load(&*conn)?;
    versions_and_publishers.sort_by(|a, b| b.0.num.cmp(&a.0.num));
    let versions = versions_and_publishers
        .iter()
        .map(|(v, _)| v)
        .cloned()
        .collect::<Vec<_>>();
    let versions = versions_and_publishers
        .into_iter()
        .zip(VersionOwnerAction::for_versions(&conn, &versions)?.into_iter())
        .map(|((v, pb), aas)| v.encodable(crate_name, pb, aas))
        .collect();
    #[derive(Serialize)]
    struct R {
        versions: Vec<EncodableVersion>,
    }
    Ok(req.json(&R { versions }))
}
pub fn versions ( req : & mut dyn Request ) -> AppResult < Response > { let crate_name = & req . params ( ) [ " " ] ; let conn = req . db_read_only ( ) ? ; let krate = Crate :: by_name ( crate_name ) . first :: < Crate > ( & * conn ) ? ; let mut versions_and_publishers : Vec < ( Version , Option < User > ) > = krate . all_versions ( ) . left_outer_join ( users :: table ) . select ( ( versions :: all_columns , users :: all_columns . nullable ( ) ) ) . load ( & * conn ) ? ; versions_and_publishers . sort_by ( | a , b | b . 0 . num . cmp ( & a . 0 . num ) ) ; let versions = versions_and_publishers . iter ( ) . map ( | ( v , _ ) | v ) . cloned ( ) . collect :: < Vec < _ > > ( ) ; let versions = versions_and_publishers . into_iter ( ) . zip ( VersionOwnerAction :: for_versions ( & conn , & versions ) ? . into_iter ( ) ) . map ( | ( ( v , pb ) , aas ) | v . encodable ( crate_name , pb , aas ) ) . collect ( ) ; # [ derive ( Serialize ) ] struct R { versions : Vec < EncodableVersion > , } Ok ( req . json ( & R { versions } ) ) }
Handles the `GET /crates/:crate_id/versions` route.
Handles the ` GET / crates / : crate_id / versions ` route .
req
&mut dyn Request