about summary refs log tree commit diff
path: root/src/liballoc
diff options
context:
space:
mode:
authorSimon Sapin <simon.sapin@exyr.org>2018-04-04 16:03:46 +0200
committerSimon Sapin <simon.sapin@exyr.org>2018-04-12 22:53:13 +0200
commitb017742136a5d02b6ba0f2080e97d18a8bfeba4b (patch)
treebce8f7a832eb5cb80d05a45ef5e562c274b0ff6b /src/liballoc
parentf9c96d70bd1471f662aa2ffdfe30ab6df69629d1 (diff)
downloadrust-b017742136a5d02b6ba0f2080e97d18a8bfeba4b.tar.gz
rust-b017742136a5d02b6ba0f2080e97d18a8bfeba4b.zip
Return Result instead of Option in alloc::Layout constructors
Diffstat (limited to 'src/liballoc')
-rw-r--r--src/liballoc/raw_vec.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/liballoc/raw_vec.rs b/src/liballoc/raw_vec.rs
index d7c30925f1a..18aaf1de08e 100644
--- a/src/liballoc/raw_vec.rs
+++ b/src/liballoc/raw_vec.rs
@@ -422,7 +422,7 @@ impl<T, A: Alloc> RawVec<T, A> {
 
             // Nothing we can really do about these checks :(
             let new_cap = used_cap.checked_add(needed_extra_cap).ok_or(CapacityOverflow)?;
-            let new_layout = Layout::array::<T>(new_cap).ok_or(CapacityOverflow)?;
+            let new_layout = Layout::array::<T>(new_cap).map_err(|_| CapacityOverflow)?;
 
             alloc_guard(new_layout.size())?;
 
@@ -530,7 +530,7 @@ impl<T, A: Alloc> RawVec<T, A> {
             }
 
             let new_cap = self.amortized_new_size(used_cap, needed_extra_cap)?;
-            let new_layout = Layout::array::<T>(new_cap).ok_or(CapacityOverflow)?;
+            let new_layout = Layout::array::<T>(new_cap).map_err(|_| CapacityOverflow)?;
 
              // FIXME: may crash and burn on over-reserve
             alloc_guard(new_layout.size())?;