17 lines
572 B
Rust
17 lines
572 B
Rust
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
let s = std::fs::read_to_string("./cargo.lock")?;
|
|
let lock = s.parse::<toml::Value>().unwrap();
|
|
let mut reqwest_ver: Option<String> = None;
|
|
for p in lock.as_table().unwrap()["package"].as_array().unwrap() {
|
|
if p["name"].as_str().unwrap() == "reqwest" {
|
|
reqwest_ver = Some(p["version"].as_str().unwrap().into());
|
|
break;
|
|
}
|
|
}
|
|
println!(
|
|
"cargo:rustc-env=REQWEST_VER={}",
|
|
reqwest_ver.ok_or_else(|| "No reqwest ver found")?
|
|
);
|
|
Ok(())
|
|
}
|