AllocError enumv0.1.0
pub enum AllocError: uint8 {
Unsupported = 1,
OutOfMemory = 2,
InvalidBlock = 3
}
Cases
| Name | Value | Description |
|---|---|---|
Unsupported | 1 | The layout cannot be served by this allocator at all: an alignment stricter than it can give, or a size it could never hold. A different allocator might succeed; retrying with this one will not. |
OutOfMemory | 2 | The allocator has no storage left. A smaller request might succeed, and so might this one later. |
InvalidBlock | 3 | The arguments do not describe an allocation this allocator handed out — a pointer it did not give, or a layout that does not match the one it was given with. This is a caller's mistake rather than a shortage. |
Methods
IsTransient
pub func IsTransient(self) -> bool
Whether a later attempt could plausibly succeed.
self is borrowed. True only for OutOfMemory, which is a shortage rather than a mistake: Unsupported and
InvalidBlock describe the request rather than the moment, so repeating either gives the same answer.
Returns: whether asking again later could succeed
Related
AllocationFailed
pub func AllocationFailed(error: AllocError)
Terminates the program, reporting that an allocation was refused and why.
This is what an owning type does when the storage it needs cannot be had: running out of memory is not an error
its caller is expected to handle, and code that can recover calls the type's Try* operation instead. Does not
unwind, so no destructor runs.
A size that cannot be represented at all, such as a capacity whose byte count overflows, is reported as
Unsupported: no allocator could serve it.
Parameters
| Name | Type | Description |
|---|---|---|
error | AllocError | why the allocator refused |