about summary refs log tree commit diff
path: root/src/libstd/slice.rs
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-05-17 00:56:00 -0700
committerAlex Crichton <alex@alexcrichton.com>2014-05-20 23:06:54 -0700
commit19dc3b50bd63489988eb8fc83d25b08ca83df151 (patch)
treee5e2cdf9ce3389bdf871f3c99128a9b992de63a6 /src/libstd/slice.rs
parent1ba7bd10c9c537687ca393eca0b323569309b83a (diff)
downloadrust-19dc3b50bd63489988eb8fc83d25b08ca83df151.tar.gz
rust-19dc3b50bd63489988eb8fc83d25b08ca83df151.zip
core: Stabilize the mem module
Excluding the functions inherited from the cast module last week (with marked
stability levels), these functions received the following treatment.

* size_of - this method has become #[stable]
* nonzero_size_of/nonzero_size_of_val - these methods have been removed
* min_align_of - this method is now #[stable]
* pref_align_of - this method has been renamed without the
  `pref_` prefix, and it is the "default alignment" now. This decision is in line
  with what clang does (see url linked in comment on function). This function
  is now #[stable].
* init - renamed to zeroed and marked #[stable]
* uninit - marked #[stable]
* move_val_init - renamed to overwrite and marked #[stable]
* {from,to}_{be,le}{16,32,64} - all functions marked #[stable]
* swap/replace/drop - marked #[stable]
* size_of_val/min_align_of_val/align_of_val - these functions are marked
  #[unstable], but will continue to exist in some form. Concerns have been
  raised about their `_val` prefix.

[breaking-change]
Diffstat (limited to 'src/libstd/slice.rs')
-rw-r--r--src/libstd/slice.rs8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/libstd/slice.rs b/src/libstd/slice.rs
index 66471ee3923..e78122f699d 100644
--- a/src/libstd/slice.rs
+++ b/src/libstd/slice.rs
@@ -306,8 +306,10 @@ impl<'a, T: Clone> CloneableVector<T> for &'a [T] {
             // this should pass the real required alignment
             let ret = exchange_malloc(size, 8) as *mut RawVec<()>;
 
-            (*ret).fill = len * mem::nonzero_size_of::<T>();
-            (*ret).alloc = len * mem::nonzero_size_of::<T>();
+            let a_size = mem::size_of::<T>();
+            let a_size = if a_size == 0 {1} else {a_size};
+            (*ret).fill = len * a_size;
+            (*ret).alloc = len * a_size;
 
             // Be careful with the following loop. We want it to be optimized
             // to a memcpy (or something similarly fast) when T is Copy. LLVM
@@ -318,7 +320,7 @@ impl<'a, T: Clone> CloneableVector<T> for &'a [T] {
             try_finally(
                 &mut i, (),
                 |i, ()| while *i < len {
-                    mem::move_val_init(
+                    mem::overwrite(
                         &mut(*p.offset(*i as int)),
                         self.unsafe_ref(*i).clone());
                     *i += 1;