Skip to content

Commit

Permalink
Make Dependency's source member the same type as Package's `sou…
Browse files Browse the repository at this point in the history
…rce` member: `Option<Source>`
  • Loading branch information
regexident committed Dec 3, 2024
1 parent 834207b commit 632bf2b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- Updated dependencies:
- `thiserror` from `1.0.31` to `2.0.3`
- `derive_builder` from `0.12` to `0.20`
- Made `Dependency`'s `source` member the same type as `Package`'s `source` member: `Option<Source>`.

### Removed

Expand Down
4 changes: 3 additions & 1 deletion src/dependency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub struct Dependency {
/// Name as given in the `Cargo.toml`
pub name: String,
/// The source of dependency
pub source: Option<String>,
pub source: Option<Source>,
/// The required version
pub req: VersionReq,
/// The kind of dependency this is
Expand Down Expand Up @@ -83,3 +83,5 @@ pub struct Dependency {
}

pub use cargo_platform::Platform;

use crate::Source;
6 changes: 4 additions & 2 deletions tests/test_samples.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ extern crate serde_json;
use camino::Utf8PathBuf;
use cargo_metadata::{
workspace_default_members_is_missing, ArtifactDebuginfo, CargoOpt, DependencyKind, Edition,
Message, Metadata, MetadataCommand,
Message, Metadata, MetadataCommand, Source,
};

/// Output from oldest version ever supported (1.24).
Expand Down Expand Up @@ -240,7 +240,9 @@ fn all_the_fields() {
.unwrap();
assert_eq!(
bitflags.source,
Some("registry+https://github.com/rust-lang/crates.io-index".to_string())
Some(Source {
repr: "registry+https://github.com/rust-lang/crates.io-index".to_string()
})
);
assert!(bitflags.optional);
assert_eq!(bitflags.req, semver::VersionReq::parse("^1.0").unwrap());
Expand Down

0 comments on commit 632bf2b

Please sign in to comment.