News for hackers. Stuff that matters.
Re:Rust vs Go: A Hands-On Comparison by llimllib on Wednesday September 27, 2023 @01:40PM (#37678236)
That's not a fair comparison, this is what it maps to in rust:

    let lat_long = fetch_lat_long(&params.city)
        .await
        .map_err(|_| StatusCode::NOT_FOUND)?;
    let weather = fetch_weather(lat_long)
        .await
        .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?;
    let display = WeatherDisplay {
        city: params.city,
        forecasts: weather
            .hourly
            .time
            .iter()
            .zip(weather.hourly.temperature_2m.iter())
            .map(|(date, temperature)| Forecast {
                date: date.to_string(),
                temperature: temperature.to_string(),
            })
            .collect(),
    };
    Ok(format!("{:?}", display))
which is almost exactly line-for-line equivalent

There are no comments on this comment yet.