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

allow using workspace = true in Cargo.toml, fixes #16 #19

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion src/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,32 @@ pub struct Manifest {
pub package: Package,
}

#[derive(Deserialize, Debug, PartialEq)]
pub struct Workspace {
workspace: bool,
}

#[derive(Deserialize, Debug, PartialEq)]
#[serde(untagged)]
pub enum Version {
Str(String),
Map(Workspace),
}

#[derive(Deserialize)]
pub struct Package {
pub name: String,
pub version: String,
pub version: Version,
pub description: Option<String>,
}

#[cfg(test)]
mod tests {
use toml;

use crate::manifest::Workspace;
use crate::manifest::Version;

use super::Manifest;

#[test]
Expand Down Expand Up @@ -60,4 +75,19 @@ description = "Test description"

assert_eq!(manifest.package.description.unwrap(), "Test description");
}

#[test]
fn version_is_workspace() {
let manifest: Manifest = toml::from_str(
r#"
[package]
name = "foo"
version = { workspace = true }
description = "Test description"
"#,
)
.unwrap();

assert_eq!(manifest.package.version, Version::Map(Workspace{workspace: true}));
}
}