diff --git a/src/cmd/edit.rs b/src/cmd/edit.rs index c09669f..665d580 100644 --- a/src/cmd/edit.rs +++ b/src/cmd/edit.rs @@ -137,12 +137,21 @@ impl Edit { Err(err) => return Err(err), }; - // Insert [patch.crates-io] table if it doesn't exist. - if let Item::None = manifest[PATCH_TABLE_NAME][REGISTRY_TABLE_NAME] { + if manifest.get(PATCH_TABLE_NAME).is_none() { let mut t = Table::new(); t.set_implicit(true); manifest[PATCH_TABLE_NAME] = Item::Table(t); - manifest[PATCH_TABLE_NAME][REGISTRY_TABLE_NAME] = Item::Table(Table::new()); + } + + // Insert [patch.crates-io] table if it doesn't exist. + if manifest + .get(PATCH_TABLE_NAME) + .unwrap() + .get(REGISTRY_TABLE_NAME) + .is_none() + { + let t = Table::new(); + manifest[PATCH_TABLE_NAME][REGISTRY_TABLE_NAME] = Item::Table(t); } manifest[PATCH_TABLE_NAME][REGISTRY_TABLE_NAME][&self.crate_name]["path"] = value(new_path.to_str().unwrap());