Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parse index with csv #106

Open
pynixwang opened this issue Oct 16, 2021 · 1 comment
Open

parse index with csv #106

pynixwang opened this issue Oct 16, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@pynixwang
Copy link

use serde::Deserialize;

#[derive(Debug, Deserialize)]
struct Version {
    name: String,
    url: String,
    sha256: String
}

let resp = reqwest::blocking::get("https://cache.ruby-lang.org/pub/ruby/index.txt")?;

let mut rdr = csv::ReaderBuilder::new()
    .delimiter(b'\t')
    .from_reader(resp);
for result in rdr.deserialize() {
    let version: Version = result?;
    println!("{:?}", version);
}
@pynixwang
Copy link
Author

pynixwang commented Oct 16, 2021

much clean than regexp

@TaKO8Ki TaKO8Ki added the enhancement New feature or request label Nov 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants