Skip to content

Commit

Permalink
Change typeof Args::targets to Option<Vec<String>> (rust-lang#327)
Browse files Browse the repository at this point in the history
* Change typeof `Args::targets` to `Option<Vec<String>>`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
  • Loading branch information
NobodyXu authored Aug 31, 2022
1 parent 480ea19 commit b330a18
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion crates/bin/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub struct Args {
long,
value_name = "TRIPLE"
)]
pub targets: Option<String>,
pub targets: Option<Vec<String>>,

/// Override Cargo.toml package manifest path.
///
Expand Down
2 changes: 1 addition & 1 deletion crates/bin/src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub async fn install_crates(mut args: Args, jobserver_client: LazyJobserverClien
};

// Launch target detection
let desired_targets = get_desired_targets(args.targets.as_deref());
let desired_targets = get_desired_targets(args.targets.take());

// Initialize reqwest client
let client = create_reqwest_client(args.secure, args.min_tls_version.map(|v| v.into()))?;
Expand Down
4 changes: 2 additions & 2 deletions crates/detect-targets/src/desired_targets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ impl DesiredTargets {
/// Since `detect_targets` internally spawns a process and wait for it,
/// it's pretty costy, it is recommended to run this fn ASAP and
/// reuse the result.
pub fn get_desired_targets(opts_targets: Option<&str>) -> DesiredTargets {
pub fn get_desired_targets(opts_targets: Option<Vec<String>>) -> DesiredTargets {
if let Some(targets) = opts_targets {
DesiredTargets::initialized(targets.split(',').map(|t| t.to_string()).collect())
DesiredTargets::initialized(targets)
} else {
DesiredTargets::auto_detect()
}
Expand Down
5 changes: 4 additions & 1 deletion crates/detect-targets/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@
//! # async fn main() {
//!
//! assert_eq!(
//! get_desired_targets(Some("x86_64-apple-darwin,aarch64-apple-darwin")).get().await,
//! get_desired_targets(Some(vec![
//! "x86_64-apple-darwin".to_string(),
//! "aarch64-apple-darwin".to_string(),
//! ])).get().await,
//! &["x86_64-apple-darwin", "aarch64-apple-darwin"],
//! );
//! # }
Expand Down

0 comments on commit b330a18

Please sign in to comment.