diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2017-08-14 19:36:13 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2017-08-14 19:36:13 -0700 |
| commit | 1413253a41de87ce7da73f0733aa3f433b1f5a3b (patch) | |
| tree | 111cba46a53aaaa0733b6b8ba19aece25b6f8533 /src/liballoc/allocator.rs | |
| parent | b045c201b2086073f43d76290b9cb2a5a8e16f89 (diff) | |
| parent | 56fe3b2ad0055bb28325f412395577e2b842719a (diff) | |
| download | rust-1413253a41de87ce7da73f0733aa3f433b1f5a3b.tar.gz rust-1413253a41de87ce7da73f0733aa3f433b1f5a3b.zip | |
Merge remote-tracking branch 'origin/master' into gen
Diffstat (limited to 'src/liballoc/allocator.rs')
| -rw-r--r-- | src/liballoc/allocator.rs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/liballoc/allocator.rs b/src/liballoc/allocator.rs index 42111301a9f..2b3df15f716 100644 --- a/src/liballoc/allocator.rs +++ b/src/liballoc/allocator.rs @@ -40,7 +40,7 @@ fn size_align<T>() -> (usize, usize) { /// /// (Note however that layouts are *not* required to have positive /// size, even though many allocators require that all memory -/// requeusts have positive size. A caller to the `Alloc::alloc` +/// requests have positive size. A caller to the `Alloc::alloc` /// method must either ensure that conditions like this are met, or /// use specific allocators with looser requirements.) #[derive(Clone, Debug, PartialEq, Eq)] @@ -240,7 +240,7 @@ impl Layout { /// /// Returns `Some((k, offset))`, where `k` is layout of the concatenated /// record and `offset` is the relative location, in bytes, of the - /// start of the `next` embedded witnin the concatenated record + /// start of the `next` embedded within the concatenated record /// (assuming that the record itself starts at offset 0). /// /// On arithmetic overflow, returns `None`. @@ -297,7 +297,7 @@ impl Layout { /// /// Returns `(k, offset)`, where `k` is layout of the concatenated /// record and `offset` is the relative location, in bytes, of the - /// start of the `next` embedded witnin the concatenated record + /// start of the `next` embedded within the concatenated record /// (assuming that the record itself starts at offset 0). /// /// (The `offset` is always the same as `self.size()`; we use this @@ -354,15 +354,19 @@ pub enum AllocErr { } impl AllocErr { + #[inline] pub fn invalid_input(details: &'static str) -> Self { AllocErr::Unsupported { details: details } } + #[inline] pub fn is_memory_exhausted(&self) -> bool { if let AllocErr::Exhausted { .. } = *self { true } else { false } } + #[inline] pub fn is_request_unsupported(&self) -> bool { if let AllocErr::Unsupported { .. } = *self { true } else { false } } + #[inline] pub fn description(&self) -> &str { match *self { AllocErr::Exhausted { .. } => "allocator memory exhausted", @@ -544,7 +548,7 @@ pub unsafe trait Alloc { /// practice this means implementors should eschew allocating, /// especially from `self` (directly or indirectly). /// - /// Implementions of the allocation and reallocation methods + /// Implementations of the allocation and reallocation methods /// (e.g. `alloc`, `alloc_one`, `realloc`) are discouraged from /// panicking (or aborting) in the event of memory exhaustion; /// instead they should return an appropriate error from the |
