@@ -49,26 +49,26 @@ impl fmt::Display for AllocError {
49
49
/// An implementation of `Allocator` can allocate, grow, shrink, and deallocate arbitrary blocks of
50
50
/// data described via [`Layout`][].
51
51
///
52
- /// `Allocator` is designed to be implemented on ZSTs, references, or smart pointers because having
53
- /// an allocator like `MyAlloc([u8; N])` cannot be moved, without updating the pointers to the
52
+ /// `Allocator` is designed to be implemented on ZSTs, references, or smart pointers.
53
+ /// An allocator for `MyAlloc([u8; N])` cannot be moved, without updating the pointers to the
54
54
/// allocated memory.
55
55
///
56
- /// Unlike [`GlobalAlloc`][], zero-sized allocations are allowed in `Allocator` . If an underlying
57
- /// allocator does not support this (like jemalloc) or return a null pointer (such as
58
- /// `libc::malloc`), this must be caught by the implementation.
56
+ /// In contrast to [`GlobalAlloc`][], `Allocator` allows zero-sized allocations. If an underlying
57
+ /// allocator does not support this (like jemalloc) or responds by returning a null pointer
58
+ /// (such as `libc::malloc`), this must be caught by the implementation.
59
59
///
60
60
/// ### Currently allocated memory
61
61
///
62
- /// Some of the methods require that a memory block be *currently allocated* via an allocator. This
63
- /// means that:
62
+ /// Some of the methods require that a memory block is *currently allocated* by an allocator.
63
+ /// This means that:
64
+ /// * the starting address for that memory block was previously
65
+ /// returned by [`allocate`], [`grow`], or [`shrink`], and
66
+ /// * the memory block has not subsequently been deallocated.
64
67
///
65
- /// * the starting address for that memory block was previously returned by [`allocate`], [`grow`], or
66
- /// [`shrink`], and
67
- ///
68
- /// * the memory block has not been subsequently deallocated, where blocks are either deallocated
69
- /// directly by being passed to [`deallocate`] or were changed by being passed to [`grow`] or
70
- /// [`shrink`] that returns `Ok`. If `grow` or `shrink` have returned `Err`, the passed pointer
71
- /// remains valid.
68
+ /// A memory block is deallocated by a call to [`deallocate`],
69
+ /// or by a call to [`grow`] or [`shrink`] that returns `Ok`.
70
+ /// A call to `grow` or `shrink` that returns `Err`,
71
+ /// does not deallocate the memory block passed to it.
72
72
///
73
73
/// [`allocate`]: Allocator::allocate
74
74
/// [`grow`]: Allocator::grow
@@ -77,32 +77,28 @@ impl fmt::Display for AllocError {
77
77
///
78
78
/// ### Memory fitting
79
79
///
80
- /// Some of the methods require that a layout *fit* a memory block. What it means for a layout to
81
- /// "fit" a memory block means (or equivalently, for a memory block to "fit" a layout) is that the
80
+ /// Some of the methods require that a `layout` *fit* a memory block or vice versa. This means that the
82
81
/// following conditions must hold:
83
- ///
84
- /// * The block must be allocated with the same alignment as [`layout.align()`], and
85
- ///
86
- /// * The provided [`layout.size()`] must fall in the range `min ..= max`, where:
87
- /// - `min` is the size of the layout most recently used to allocate the block, and
88
- /// - `max` is the latest actual size returned from [`allocate`], [`grow`], or [`shrink`].
82
+ /// * the memory block must be *currently allocated* with alignment of [`layout.align()`], and
83
+ /// * [`layout.size()`] must fall in the range `min ..= max`, where:
84
+ /// - `min` is the size of the layout used to allocate the block, and
85
+ /// - `max` is the actual size returned from [`allocate`], [`grow`], or [`shrink`].
89
86
///
90
87
/// [`layout.align()`]: Layout::align
91
88
/// [`layout.size()`]: Layout::size
92
89
///
93
90
/// # Safety
94
91
///
95
- /// * Memory blocks returned from an allocator that are [*currently allocated*] must point to
96
- /// valid memory and retain their validity while they are [*currently allocated*] and the shorter
97
- /// of:
98
- /// - the borrow-checker lifetime of the allocator type itself.
99
- /// - as long as at least one of the instance and all of its clones has not been dropped.
92
+ /// Memory blocks that are [*currently allocated*] by an allocator,
93
+ /// must point to valid memory, and retain their validity while until either:
94
+ /// - the memory block is deallocated, or
95
+ /// - the allocator is dropped.
100
96
///
101
- /// * copying , cloning, or moving the allocator must not invalidate memory blocks returned from this
102
- /// allocator. A copied or cloned allocator must behave like the same allocator, and
97
+ /// Copying , cloning, or moving the allocator must not invalidate memory blocks returned from it
98
+ /// A copied or cloned allocator must behave like the original allocator.
103
99
///
104
- /// * any pointer to a memory block which is [*currently allocated*] may be passed to any other
105
- /// method of the allocator.
100
+ /// A memory block which is [*currently allocated*] may be passed to
101
+ /// any method of the allocator that accepts such an argument .
106
102
///
107
103
/// [*currently allocated*]: #currently-allocated-memory
108
104
#[ unstable( feature = "allocator_api" , issue = "32838" ) ]
0 commit comments