diff options
| author | bors <bors@rust-lang.org> | 2021-01-22 21:48:41 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-01-22 21:48:41 +0000 |
| commit | 34b3d41e1ad74983943c05e382a1750cdf6d2b33 (patch) | |
| tree | b59246c8914a5623eab8e4cabeba319ac7d91574 /library/alloc/src/macros.rs | |
| parent | 22ddcd1a13082b7be0fc99b720677efd2b733816 (diff) | |
| parent | 7d102383f97c1616cffce5ca72ff12eabd9603bf (diff) | |
| download | rust-34b3d41e1ad74983943c05e382a1750cdf6d2b33.tar.gz rust-34b3d41e1ad74983943c05e382a1750cdf6d2b33.zip | |
Auto merge of #79233 - yoshuawuyts:alloc-doc-alias, r=GuillaumeGomez
Add doc aliases for memory allocations
This patch adds doc aliases for various C allocation functions, making it possible to search for the C-equivalent of a function and finding the (safe) Rust counterpart:
- `Vec::with_capacity` / `Box::new` / `vec!` -> alloc + malloc, allocates memory
- `Box::new_zeroed` -> calloc, allocates zeroed-out memory
- `Vec::{reserve,reserve_exact,try_reserve_exact,shrink_to_fit,shrink_to}` -> realloc, reallocates a previously allocated slice of memory
It's worth noting that `Vec::new` does not allocate, so we don't link to it. Instead people are probably looking for `Vec::with_capacity` or `vec!`. I hope this will allow people comfortable with the system allocation APIs to make it easier to find what they may be looking for.
Thanks!
Diffstat (limited to 'library/alloc/src/macros.rs')
| -rw-r--r-- | library/alloc/src/macros.rs | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/library/alloc/src/macros.rs b/library/alloc/src/macros.rs index f1e3ee97ccc..a64a8b32ad7 100644 --- a/library/alloc/src/macros.rs +++ b/library/alloc/src/macros.rs @@ -35,6 +35,8 @@ /// /// [`Vec`]: crate::vec::Vec #[cfg(not(test))] +#[doc(alias = "alloc")] +#[doc(alias = "malloc")] #[macro_export] #[stable(feature = "rust1", since = "1.0.0")] #[allow_internal_unstable(box_syntax, liballoc_internals)] |
