Skip to content

Commit 8e9c8dd

Browse files
committed
Add information about allocation lifetime to Allocator::allocate
1 parent fb5ed29 commit 8e9c8dd

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

library/core/src/alloc/mod.rs

+4
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ pub unsafe trait Allocator {
116116
/// The returned block may have a larger size than specified by `layout.size()`, and may or may
117117
/// not have its contents initialized.
118118
///
119+
/// The returned block of memory remains valid as long as it is [*currently allocated*] and the shorter of:
120+
/// - the borrow-checker lifetime of the allocator type itself.
121+
/// - as long as at the allocator and all its clones has not been dropped.
122+
///
119123
/// # Errors
120124
///
121125
/// Returning `Err` indicates that either memory is exhausted or `layout` does not meet

0 commit comments

Comments
 (0)