Note: This site is currently "Under construction". I'm migrating to a new version of my site building software. Lots of things are in a state of disrepair as a result (for example, footnote links aren't working). It's all part of the process of building in public. Most things should still be readable though.

Get Querystring Params From A URL In Rust

This is what I'm doing to get query params in Rust:

Code

use url::Url;

fn main() {
    let url = Url::parse("https://www.example.com/index.html?alfa=bravo&charlie=delta")
        .expect("Could not parse url");
    let query_pairs = url.query_pairs();
    query_pairs.for_each(|param| {
        println!("key: {}, value: {}", param.0, param.1);
        ()
    });
}