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