mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-25 11:14:46 +00:00
HashMap::from not into
This commit is contained in:
parent
4bfed40178
commit
96dc595eaf
@ -30,7 +30,7 @@ pub fn expand(file: &Path, formatter: FormatterRef) -> Result<String, Error> {
|
||||
.to_str()
|
||||
.expect("utf8 filename")
|
||||
.to_string();
|
||||
let data: HashMap<String, String> = [("man_name", man_name)].into();
|
||||
let data = HashMap::from([("man_name", man_name)]);
|
||||
let expanded = handlebars.render("template", &data)?;
|
||||
Ok(expanded)
|
||||
}
|
||||
|
@ -13,12 +13,10 @@ pub fn cli() -> App {
|
||||
|
||||
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
|
||||
if let Err(e) = args.workspace(config) {
|
||||
let h: HashMap<_, _> = [("invalid", e.to_string())].into();
|
||||
config.shell().print_json(&h)?;
|
||||
config.shell().print_json(&HashMap::from([("invalid", e.to_string())]))?;
|
||||
process::exit(1)
|
||||
}
|
||||
|
||||
let h: HashMap<_, _> = [("success", "true")].into();
|
||||
config.shell().print_json(&h)?;
|
||||
config.shell().print_json(&HashMap::from([("success", "true")]))?;
|
||||
Ok(())
|
||||
}
|
||||
|
@ -64,9 +64,8 @@ pub struct RustdocExternMap {
|
||||
|
||||
impl Default for RustdocExternMap {
|
||||
fn default() -> Self {
|
||||
let registries = [(CRATES_IO_REGISTRY.into(), DOCS_RS_URL.into())].into();
|
||||
Self {
|
||||
registries,
|
||||
registries: HashMap::from([(CRATES_IO_REGISTRY.into(), DOCS_RS_URL.into())]),
|
||||
std: None,
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ pub fn resolve_std<'cfg>(
|
||||
})
|
||||
.collect::<CargoResult<Vec<_>>>()?;
|
||||
let crates_io_url = crate::sources::CRATES_IO_INDEX.parse().unwrap();
|
||||
let patch = [(crates_io_url, patches)].into();
|
||||
let patch = HashMap::from([(crates_io_url, patches)]);
|
||||
let members = vec![
|
||||
String::from("library/std"),
|
||||
String::from("library/core"),
|
||||
|
@ -1171,7 +1171,7 @@ impl Config {
|
||||
})?
|
||||
.to_string();
|
||||
let value = CV::String(str_path, Definition::Cli);
|
||||
let map = [("include".to_string(), value)].into();
|
||||
let map = HashMap::from([("include".to_string(), value)]);
|
||||
CV::Table(map, Definition::Cli)
|
||||
} else {
|
||||
// We only want to allow "dotted key" (see https://toml.io/en/v1.0.0#keys)
|
||||
@ -1416,7 +1416,7 @@ impl Config {
|
||||
|
||||
if let Some(token) = value_map.remove("token") {
|
||||
if let Vacant(entry) = value_map.entry("registry".into()) {
|
||||
let map = [("token".into(), token)].into();
|
||||
let map = HashMap::from([("token".into(), token)]);
|
||||
let table = CV::Table(map, def.clone());
|
||||
entry.insert(table);
|
||||
}
|
||||
@ -1990,7 +1990,7 @@ pub fn save_credentials(
|
||||
|
||||
// Move the old token location to the new one.
|
||||
if let Some(token) = toml.as_table_mut().unwrap().remove("token") {
|
||||
let map: HashMap<_, _> = [("token".to_string(), token)].into();
|
||||
let map = HashMap::from([("token".to_string(), token)]);
|
||||
toml.as_table_mut()
|
||||
.unwrap()
|
||||
.insert("registry".into(), map.into());
|
||||
@ -2001,11 +2001,11 @@ pub fn save_credentials(
|
||||
let (key, mut value) = {
|
||||
let key = "token".to_string();
|
||||
let value = ConfigValue::String(token, Definition::Path(file.path().to_path_buf()));
|
||||
let map = [(key, value)].into();
|
||||
let map = HashMap::from([(key, value)]);
|
||||
let table = CV::Table(map, Definition::Path(file.path().to_path_buf()));
|
||||
|
||||
if let Some(registry) = registry {
|
||||
let map = [(registry.to_string(), table)].into();
|
||||
let map = HashMap::from([(registry.to_string(), table)]);
|
||||
(
|
||||
"registries".into(),
|
||||
CV::Table(map, Definition::Path(file.path().to_path_buf())),
|
||||
|
Loading…
x
Reference in New Issue
Block a user