That mockingbird won't sing: a mock API server in Rust — Bitfield Consulting
bitfieldconsulting.com·5d·
Discuss: r/rust
Reactive Programming
Preview
Report Post

It’s better to be a fake somebody than a real nobody.“The Talented Mr. Ripley”

Faking it till you make it isn’t always the best strategy in life, but it can be a useful one in software engineering. In A hard rain’s a-gonna fall, we wrote some Rust code that sends requests to the Weatherstack API, and decodes its responses. So, how happy are we about the correctness of that code?

We’ve put it all into a magic function named get_weather, and we call it like this:

fn main() -> Result<()> {
let args = Args::parse();
let location = args.location.join(" ");
let weather = get_weather(&location, &args.api_key)?;
println!("{weather}");
Ok(())
}

([Listing weather_2](https://github.com/…

Similar Posts

Loading similar posts...