@@ -42,13 +42,13 @@ impl fmt::Display for AllocErr {
42
42
///
43
43
/// ### Currently allocated memory
44
44
///
45
- /// Some of the methods require that a memory slice be *currently allocated* via an allocator. This
45
+ /// Some of the methods require that a memory block be *currently allocated* via an allocator. This
46
46
/// means that:
47
47
///
48
- /// * the starting address for that memory slice was previously returned by [`alloc`], [`grow`], or
48
+ /// * the starting address for that memory block was previously returned by [`alloc`], [`grow`], or
49
49
/// [`shrink`], and
50
50
///
51
- /// * the memory slice has not been subsequently deallocated, where slices are either deallocated
51
+ /// * the memory block has not been subsequently deallocated, where blocks are either deallocated
52
52
/// directly by being passed to [`dealloc`] or were changed by being passed to [`grow`] or
53
53
/// [`shrink`] that returns `Ok`. If `grow` or `shrink` have returned `Err`, the passed pointer
54
54
/// remains valid.
@@ -60,38 +60,38 @@ impl fmt::Display for AllocErr {
60
60
///
61
61
/// ### Memory fitting
62
62
///
63
- /// Some of the methods require that a layout *fit* a memory slice . What it means for a layout to
64
- /// "fit" a memory slice means (or equivalently, for a memory slice to "fit" a layout) is that the
63
+ /// Some of the methods require that a layout *fit* a memory block . What it means for a layout to
64
+ /// "fit" a memory block means (or equivalently, for a memory block to "fit" a layout) is that the
65
65
/// following conditions must hold:
66
66
///
67
- /// * The slice must be allocated with the same alignment as [`layout.align()`], and
67
+ /// * The block must be allocated with the same alignment as [`layout.align()`], and
68
68
///
69
69
/// * The provided [`layout.size()`] must fall in the range `min ..= max`, where:
70
- /// - `min` is the size of the layout most recently used to allocate the slice , and
70
+ /// - `min` is the size of the layout most recently used to allocate the block , and
71
71
/// - `max` is the latest actual size returned from [`alloc`], [`grow`], or [`shrink`].
72
72
///
73
73
/// [`layout.align()`]: Layout::align
74
74
/// [`layout.size()`]: Layout::size
75
75
///
76
76
/// # Safety
77
77
///
78
- /// * Memory slices returned from an allocator must point to valid memory and retain their validity
78
+ /// * Memory blocks returned from an allocator must point to valid memory and retain their validity
79
79
/// until the instance and all of its clones are dropped,
80
80
///
81
- /// * cloning or moving the allocator must not invalidate memory slices returned from this
81
+ /// * cloning or moving the allocator must not invalidate memory blocks returned from this
82
82
/// allocator. A cloned allocator must behave like the same allocator, and
83
83
///
84
- /// * any pointer to a memory slice which is [*currently allocated*] may be passed to any other
84
+ /// * any pointer to a memory block which is [*currently allocated*] may be passed to any other
85
85
/// method of the allocator.
86
86
///
87
87
/// [*currently allocated*]: #currently-allocated-memory
88
88
#[ unstable( feature = "allocator_api" , issue = "32838" ) ]
89
89
pub unsafe trait AllocRef {
90
- /// Attempts to allocate a slice of memory.
90
+ /// Attempts to allocate a block of memory.
91
91
///
92
92
/// On success, returns a [`NonNull<[u8]>`] meeting the size and alignment guarantees of `layout`.
93
93
///
94
- /// The returned slice may have a larger size than specified by `layout.size()`, and may or may
94
+ /// The returned block may have a larger size than specified by `layout.size()`, and may or may
95
95
/// not have its contents initialized.
96
96
///
97
97
/// [`NonNull<[u8]>`]: NonNull
@@ -133,18 +133,18 @@ pub unsafe trait AllocRef {
133
133
Ok ( ptr)
134
134
}
135
135
136
- /// Deallocates the memory slice referenced by `ptr`.
136
+ /// Deallocates the memory referenced by `ptr`.
137
137
///
138
138
/// # Safety
139
139
///
140
- /// * `ptr` must denote a slice of memory [*currently allocated*] via this allocator, and
141
- /// * `layout` must [*fit*] that slice of memory.
140
+ /// * `ptr` must denote a block of memory [*currently allocated*] via this allocator, and
141
+ /// * `layout` must [*fit*] that block of memory.
142
142
///
143
143
/// [*currently allocated*]: #currently-allocated-memory
144
144
/// [*fit*]: #memory-fitting
145
145
unsafe fn dealloc ( & mut self , ptr : NonNull < u8 > , layout : Layout ) ;
146
146
147
- /// Attempts to extend the memory slice .
147
+ /// Attempts to extend the memory block .
148
148
///
149
149
/// Returns a new [`NonNull<[u8]>`] containing a pointer and the actual size of the allocated
150
150
/// memory. The pointer is suitable for holding data described by a new layout with `layout`’s
@@ -293,27 +293,27 @@ pub unsafe trait AllocRef {
293
293
}
294
294
}
295
295
296
- /// Attempts to shrink the memory slice .
296
+ /// Attempts to shrink the memory block .
297
297
///
298
298
/// Returns a new [`NonNull<[u8]>`] containing a pointer and the actual size of the allocated
299
299
/// memory. The pointer is suitable for holding data described by a new layout with `layout`’s
300
300
/// alignment and a size given by `new_size`. To accomplish this, the allocator may shrink the
301
301
/// allocation referenced by `ptr` to fit the new layout.
302
302
///
303
- /// If this returns `Ok`, then ownership of the memory slice referenced by `ptr` has been
303
+ /// If this returns `Ok`, then ownership of the memory block referenced by `ptr` has been
304
304
/// transferred to this allocator. The memory may or may not have been freed, and should be
305
305
/// considered unusable unless it was transferred back to the caller again via the
306
306
/// return value of this method.
307
307
///
308
- /// If this method returns `Err`, then ownership of the memory slice has not been transferred to
309
- /// this allocator, and the contents of the memory slice are unaltered.
308
+ /// If this method returns `Err`, then ownership of the memory block has not been transferred to
309
+ /// this allocator, and the contents of the memory block are unaltered.
310
310
///
311
311
/// [`NonNull<[u8]>`]: NonNull
312
312
///
313
313
/// # Safety
314
314
///
315
- /// * `ptr` must denote a slice of memory [*currently allocated*] via this allocator,
316
- /// * `layout` must [*fit*] that slice of memory (The `new_size` argument need not fit it.), and
315
+ /// * `ptr` must denote a block of memory [*currently allocated*] via this allocator,
316
+ /// * `layout` must [*fit*] that block of memory (The `new_size` argument need not fit it.), and
317
317
/// * `new_size` must be smaller than or equal to `layout.size()`.
318
318
// Note: We can't require that `new_size` is strictly smaller than `layout.size()` because of ZSTs.
319
319
// alternative: `new_size` must be smaller than `layout.size()` or both are zero
0 commit comments