Skip to content

Commit 96dc595

Browse files
committed
HashMap::from not into
1 parent 4bfed40 commit 96dc595

File tree

5 files changed

+10
-13
lines changed

5 files changed

+10
-13
lines changed

crates/mdman/src/hbs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub fn expand(file: &Path, formatter: FormatterRef) -> Result<String, Error> {
3030
.to_str()
3131
.expect("utf8 filename")
3232
.to_string();
33-
let data: HashMap<String, String> = [("man_name", man_name)].into();
33+
let data = HashMap::from([("man_name", man_name)]);
3434
let expanded = handlebars.render("template", &data)?;
3535
Ok(expanded)
3636
}

src/bin/cargo/commands/verify_project.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,10 @@ pub fn cli() -> App {
1313

1414
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
1515
if let Err(e) = args.workspace(config) {
16-
let h: HashMap<_, _> = [("invalid", e.to_string())].into();
17-
config.shell().print_json(&h)?;
16+
config.shell().print_json(&HashMap::from([("invalid", e.to_string())]))?;
1817
process::exit(1)
1918
}
2019

21-
let h: HashMap<_, _> = [("success", "true")].into();
22-
config.shell().print_json(&h)?;
20+
config.shell().print_json(&HashMap::from([("success", "true")]))?;
2321
Ok(())
2422
}

src/cargo/core/compiler/rustdoc.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,8 @@ pub struct RustdocExternMap {
6464

6565
impl Default for RustdocExternMap {
6666
fn default() -> Self {
67-
let registries = [(CRATES_IO_REGISTRY.into(), DOCS_RS_URL.into())].into();
6867
Self {
69-
registries,
68+
registries: HashMap::from([(CRATES_IO_REGISTRY.into(), DOCS_RS_URL.into())]),
7069
std: None,
7170
}
7271
}

src/cargo/core/compiler/standard_lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ pub fn resolve_std<'cfg>(
5353
})
5454
.collect::<CargoResult<Vec<_>>>()?;
5555
let crates_io_url = crate::sources::CRATES_IO_INDEX.parse().unwrap();
56-
let patch = [(crates_io_url, patches)].into();
56+
let patch = HashMap::from([(crates_io_url, patches)]);
5757
let members = vec![
5858
String::from("library/std"),
5959
String::from("library/core"),

src/cargo/util/config/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,7 +1171,7 @@ impl Config {
11711171
})?
11721172
.to_string();
11731173
let value = CV::String(str_path, Definition::Cli);
1174-
let map = [("include".to_string(), value)].into();
1174+
let map = HashMap::from([("include".to_string(), value)]);
11751175
CV::Table(map, Definition::Cli)
11761176
} else {
11771177
// We only want to allow "dotted key" (see https://toml.io/en/v1.0.0#keys)
@@ -1416,7 +1416,7 @@ impl Config {
14161416

14171417
if let Some(token) = value_map.remove("token") {
14181418
if let Vacant(entry) = value_map.entry("registry".into()) {
1419-
let map = [("token".into(), token)].into();
1419+
let map = HashMap::from([("token".into(), token)]);
14201420
let table = CV::Table(map, def.clone());
14211421
entry.insert(table);
14221422
}
@@ -1990,7 +1990,7 @@ pub fn save_credentials(
19901990

19911991
// Move the old token location to the new one.
19921992
if let Some(token) = toml.as_table_mut().unwrap().remove("token") {
1993-
let map: HashMap<_, _> = [("token".to_string(), token)].into();
1993+
let map = HashMap::from([("token".to_string(), token)]);
19941994
toml.as_table_mut()
19951995
.unwrap()
19961996
.insert("registry".into(), map.into());
@@ -2001,11 +2001,11 @@ pub fn save_credentials(
20012001
let (key, mut value) = {
20022002
let key = "token".to_string();
20032003
let value = ConfigValue::String(token, Definition::Path(file.path().to_path_buf()));
2004-
let map = [(key, value)].into();
2004+
let map = HashMap::from([(key, value)]);
20052005
let table = CV::Table(map, Definition::Path(file.path().to_path_buf()));
20062006

20072007
if let Some(registry) = registry {
2008-
let map = [(registry.to_string(), table)].into();
2008+
let map = HashMap::from([(registry.to_string(), table)]);
20092009
(
20102010
"registries".into(),
20112011
CV::Table(map, Definition::Path(file.path().to_path_buf())),

0 commit comments

Comments
 (0)