panic: inherited workspace value
Given this cut down Cargo.toml
file
[package]
name = "name"
version.workspace = true
rust-version.workspace = true
and the following code:
use cargo_toml::Manifest;
fn main() {
let raw_file_content = std::fs::read_to_string("Cargo.toml").unwrap();
match Manifest::from_str(&raw_file_content) {
Ok(manifest) => {
let package = manifest.package();
match package.rust_version() {
Some(rust_version) => println!("rust_version: {rust_version}"),
None => println!("No rust_version"),
}
println!("{:?}", package.edition());
}
Err(err) => println!("Error: {err}"),
};
}
There is a panic on calling rust_version
.
The original Cargo.toml
is from this repo: https://github.com/charles-r-earp/krnl
IMHO rust_version
should return a Result<String, Error>
.
Edited by Gabor Szabo