From 15701f7531bc7617fec08034b2478b14e85315ac Mon Sep 17 00:00:00 2001 From: Konrad Borowski Date: Sun, 31 Jan 2021 10:55:24 +0100 Subject: [PATCH] Add doc aliases for "delete" This patch adds doc aliases for "delete". The added aliases are supposed to reference usages `delete` in other programming languages. - `HashMap::remove`, `BTreeMap::remove` -> `Map#delete` and `delete` keyword in JavaScript. - `HashSet::remove`, `BTreeSet::remove` -> `Set#delete` in JavaScript. - `mem::drop` -> `delete` keyword in C++. - `fs::remove_file`, `fs::remove_dir`, `fs::remove_dir_all` -> `File#delete` in Java, `File#delete` and `Dir#delete` in Ruby. Before this change, searching for "delete" in documentation returned no results. --- library/alloc/src/collections/btree/map.rs | 1 + library/alloc/src/collections/btree/set.rs | 1 + library/core/src/mem/mod.rs | 1 + library/std/src/collections/hash/map.rs | 1 + library/std/src/collections/hash/set.rs | 1 + library/std/src/fs.rs | 3 +++ 6 files changed, 8 insertions(+) diff --git a/library/alloc/src/collections/btree/map.rs b/library/alloc/src/collections/btree/map.rs index 79dc694e6be..5554a448b5c 100644 --- a/library/alloc/src/collections/btree/map.rs +++ b/library/alloc/src/collections/btree/map.rs @@ -823,6 +823,7 @@ impl BTreeMap { /// assert_eq!(map.remove(&1), Some("a")); /// assert_eq!(map.remove(&1), None); /// ``` + #[doc(alias = "delete")] #[stable(feature = "rust1", since = "1.0.0")] pub fn remove(&mut self, key: &Q) -> Option where diff --git a/library/alloc/src/collections/btree/set.rs b/library/alloc/src/collections/btree/set.rs index c2a96dd8ef4..d39eb1fd4f9 100644 --- a/library/alloc/src/collections/btree/set.rs +++ b/library/alloc/src/collections/btree/set.rs @@ -770,6 +770,7 @@ impl BTreeSet { /// assert_eq!(set.remove(&2), true); /// assert_eq!(set.remove(&2), false); /// ``` + #[doc(alias = "delete")] #[stable(feature = "rust1", since = "1.0.0")] pub fn remove(&mut self, value: &Q) -> bool where diff --git a/library/core/src/mem/mod.rs b/library/core/src/mem/mod.rs index 64cf5286eb1..778e34e634f 100644 --- a/library/core/src/mem/mod.rs +++ b/library/core/src/mem/mod.rs @@ -889,6 +889,7 @@ pub fn replace(dest: &mut T, mut src: T) -> T { /// ``` /// /// [`RefCell`]: crate::cell::RefCell +#[doc(alias = "delete")] #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub fn drop(_x: T) {} diff --git a/library/std/src/collections/hash/map.rs b/library/std/src/collections/hash/map.rs index 28a25572dd8..27f7191831d 100644 --- a/library/std/src/collections/hash/map.rs +++ b/library/std/src/collections/hash/map.rs @@ -859,6 +859,7 @@ where /// assert_eq!(map.remove(&1), Some("a")); /// assert_eq!(map.remove(&1), None); /// ``` + #[doc(alias = "delete")] #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub fn remove(&mut self, k: &Q) -> Option diff --git a/library/std/src/collections/hash/set.rs b/library/std/src/collections/hash/set.rs index b08510d6b01..912e975aa0a 100644 --- a/library/std/src/collections/hash/set.rs +++ b/library/std/src/collections/hash/set.rs @@ -874,6 +874,7 @@ where /// assert_eq!(set.remove(&2), true); /// assert_eq!(set.remove(&2), false); /// ``` + #[doc(alias = "delete")] #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub fn remove(&mut self, value: &Q) -> bool diff --git a/library/std/src/fs.rs b/library/std/src/fs.rs index e2d4f2e6a56..43119c36cfe 100644 --- a/library/std/src/fs.rs +++ b/library/std/src/fs.rs @@ -1524,6 +1524,7 @@ impl AsInner for DirEntry { /// Ok(()) /// } /// ``` +#[doc(alias = "delete")] #[stable(feature = "rust1", since = "1.0.0")] pub fn remove_file>(path: P) -> io::Result<()> { fs_imp::unlink(path.as_ref()) @@ -1958,6 +1959,7 @@ pub fn create_dir_all>(path: P) -> io::Result<()> { /// Ok(()) /// } /// ``` +#[doc(alias = "delete")] #[stable(feature = "rust1", since = "1.0.0")] pub fn remove_dir>(path: P) -> io::Result<()> { fs_imp::rmdir(path.as_ref()) @@ -1995,6 +1997,7 @@ pub fn remove_dir>(path: P) -> io::Result<()> { /// Ok(()) /// } /// ``` +#[doc(alias = "delete")] #[stable(feature = "rust1", since = "1.0.0")] pub fn remove_dir_all>(path: P) -> io::Result<()> { fs_imp::remove_dir_all(path.as_ref())