Skip to content

Commit

Permalink
Edition bump, semver bump and reexport dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Jul 26, 2020
1 parent d1049f2 commit 70c4740
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 29 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
[package]
name = "cargo_metadata"
version = "0.10.1"
version = "0.11.0"
authors = ["Oliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>"]
repository = "https://github.com/oli-obk/cargo_metadata"
description = "structured access to the output of `cargo metadata`"
license = "MIT"
readme = "README.md"
edition = "2018"

[dependencies]
serde = "1.0.79"
Expand Down
1 change: 1 addition & 0 deletions src/dependency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use semver::VersionReq;
use serde::{Deserialize, Deserializer};
use serde_derive::{Deserialize, Serialize};
use std::fmt;

#[derive(PartialEq, Clone, Debug, Copy, Serialize, Deserialize)]
Expand Down
1 change: 1 addition & 0 deletions src/diagnostic.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! This module contains `Diagnostic` and the types/functions it uses for deserialization.

use serde_derive::{Deserialize, Serialize};
use std::fmt;

/// The error code associated to this diagnostic.
Expand Down
26 changes: 12 additions & 14 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,29 +78,24 @@
//! let output = command.wait().expect("Couldn't get cargo's exit status");
//! ```

extern crate semver;
extern crate serde;
#[macro_use]
extern crate serde_derive;
extern crate serde_json;

use std::collections::HashMap;
use std::env;
use std::fmt;
use std::path::PathBuf;
use std::process::Command;
use std::str::from_utf8;

use semver::Version;
pub use semver::Version;

pub use dependency::{Dependency, DependencyKind};
use diagnostic::Diagnostic;
pub use errors::{Error, Result};
pub use messages::{
Artifact, ArtifactProfile, BuildFinished, BuildScript, CompilerMessage, Message, MessageIter
};
#[allow(deprecated)]
pub use messages::parse_messages;
pub use messages::{
Artifact, ArtifactProfile, BuildFinished, BuildScript, CompilerMessage, Message, MessageIter,
};
use serde_derive::{Deserialize, Serialize};

mod dependency;
pub mod diagnostic;
Expand Down Expand Up @@ -322,9 +317,12 @@ pub struct Package {
impl Package {
/// Full path to the license file if one is present in the manifest
pub fn license_file(&self) -> Option<PathBuf> {
self.license_file
.as_ref()
.map(|file| self.manifest_path.parent().unwrap_or(&self.manifest_path).join(file))
self.license_file.as_ref().map(|file| {
self.manifest_path
.parent()
.unwrap_or(&self.manifest_path)
.join(file)
})
}

/// Full path to the readme file if one is present in the manifest
Expand Down Expand Up @@ -556,7 +554,7 @@ impl MetadataCommand {

/// Parses `cargo metadata` output. `data` must have been
/// produced by a command built with `cargo_command`.
pub fn parse<T : AsRef<str>>(data : T) -> Result<Metadata> {
pub fn parse<T: AsRef<str>>(data: T) -> Result<Metadata> {
let meta = serde_json::from_str(data.as_ref())?;
Ok(meta)
}
Expand Down
2 changes: 1 addition & 1 deletion src/messages.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::{Diagnostic, PackageId, Target};
use serde_json;
use serde_derive::{Deserialize, Serialize};
use std::fmt;
use std::io::{self, BufRead, Lines, Read};
use std::path::PathBuf;
Expand Down
20 changes: 7 additions & 13 deletions tests/test_samples.rs
Original file line number Diff line number Diff line change
Expand Up @@ -524,23 +524,20 @@ fn advanced_feature_configuration() {
// Manually specify the same default features
let manual_features = build_features(|meta| {
meta.features(CargoOpt::NoDefaultFeatures)
.features(CargoOpt::SomeFeatures(vec!["feat1".into(), "bitflags".into()]))
.features(CargoOpt::SomeFeatures(vec![
"feat1".into(),
"bitflags".into(),
]))
});
assert_eq!(
sorted!(manual_features),
vec!["bitflags", "feat1"]
);
assert_eq!(sorted!(manual_features), vec!["bitflags", "feat1"]);

// Multiple SomeFeatures is same as one longer SomeFeatures
let manual_features = build_features(|meta| {
meta.features(CargoOpt::NoDefaultFeatures)
.features(CargoOpt::SomeFeatures(vec!["feat1".into()]))
.features(CargoOpt::SomeFeatures(vec!["feat2".into()]))
});
assert_eq!(
sorted!(manual_features),
vec!["feat1", "feat2"]
);
assert_eq!(sorted!(manual_features), vec!["feat1", "feat2"]);

// No features + All features == All features
let all_features = build_features(|meta| {
Expand All @@ -558,8 +555,5 @@ fn advanced_feature_configuration() {
.features(CargoOpt::NoDefaultFeatures)
.features(CargoOpt::AllFeatures)
});
assert_eq!(
sorted!(all_flag_variants),
sorted!(all_features)
);
assert_eq!(sorted!(all_flag_variants), sorted!(all_features));
}

0 comments on commit 70c4740

Please sign in to comment.