Skip to content

Commit

Permalink
Use Into<OsString> not String
Browse files Browse the repository at this point in the history
  • Loading branch information
illicitonion committed Jan 31, 2023
1 parent 48c2753 commit 3da1b27
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ use camino::Utf8PathBuf;
use derive_builder::Builder;
use std::collections::HashMap;
use std::env;
use std::ffi::OsString;
use std::fmt;
use std::hash::Hash;
use std::path::PathBuf;
Expand Down Expand Up @@ -594,7 +595,7 @@ pub struct MetadataCommand {
other_options: Vec<String>,
/// Arbitrary environment variables to set when running `cargo`. These will be merged into
/// the calling environment, overriding any which clash.
env: HashMap<String, String>,
env: HashMap<OsString, OsString>,
/// Show stderr
verbose: bool,
}
Expand Down Expand Up @@ -704,13 +705,13 @@ impl MetadataCommand {
/// ```no_run
/// # use cargo_metadata::{CargoOpt, MetadataCommand};
/// MetadataCommand::new()
/// .env(String::from("CARGO_NET_GIT_FETCH_WITH_CLI"), String::from("true"))
/// .env(String::from("RUSTC"), String::from("/path/to/rustc"))
/// .env("CARGO_NET_GIT_FETCH_WITH_CLI", "true")
/// .env("RUSTC", "/path/to/rustc")
/// // ...
/// # ;
/// ```
pub fn env(&mut self, key: String, val: String) -> &mut MetadataCommand {
self.env.insert(key, val);
pub fn env<K: Into<OsString>, V: Into<OsString>>(&mut self, key: K, val: V) -> &mut MetadataCommand {
self.env.insert(key.into(), val.into());
self
}

Expand Down

0 comments on commit 3da1b27

Please sign in to comment.