diff options
| author | bors <bors@rust-lang.org> | 2014-04-20 10:21:32 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-04-20 10:21:32 -0700 |
| commit | 4d496933dcd8d1b6a3656f3d5008956dcb4517c1 (patch) | |
| tree | 63dd5475e983d289d92d83f8b430fa99e78317c4 | |
| parent | a27dc534e4dd01b9fb5cf7c5c30f2b2694b78d85 (diff) | |
| parent | e36adee3ae498cbf98e463f68372dca8ac8e20ac (diff) | |
| download | rust-4d496933dcd8d1b6a3656f3d5008956dcb4517c1.tar.gz rust-4d496933dcd8d1b6a3656f3d5008956dcb4517c1.zip | |
auto merge of #13643 : aochagavia/rust/pr-2, r=alexcrichton
Fixed a typo in the documentation of std::mem, and refactored a function to use match instead of if. Also added a FIXME to the benchmarks at the end of the file stating that they should be moved to another place, because they have nothing to do with `mem` (see https://github.com/mozilla/rust/issues/13642)
| -rw-r--r-- | src/libstd/mem.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/libstd/mem.rs b/src/libstd/mem.rs index d562aa73d78..342e565572b 100644 --- a/src/libstd/mem.rs +++ b/src/libstd/mem.rs @@ -37,8 +37,10 @@ pub fn size_of_val<T>(_val: &T) -> uint { /// Useful for building structures containing variable-length arrays. #[inline] pub fn nonzero_size_of<T>() -> uint { - let s = size_of::<T>(); - if s == 0 { 1 } else { s } + match size_of::<T>() { + 0 => 1, + x => x + } } /// Returns the size in bytes of the type of the value that `_val` points to. @@ -222,7 +224,6 @@ pub unsafe fn move_val_init<T>(dst: &mut T, src: T) { /// On big endian, this is a no-op. On little endian, the bytes are swapped. #[cfg(target_endian = "big")] #[inline] pub fn from_be64(x: u64) -> u64 { x } - /** * Swap the values at two mutable locations of the same type, without * deinitialising or copying either one. @@ -238,7 +239,7 @@ pub fn swap<T>(x: &mut T, y: &mut T) { ptr::copy_nonoverlapping_memory(x, &*y, 1); ptr::copy_nonoverlapping_memory(y, &t, 1); - // y and t now point to the same thing, but we need to completely forget `tmp` + // y and t now point to the same thing, but we need to completely forget `t` // because it's no longer relevant. cast::forget(t); } @@ -360,6 +361,7 @@ mod tests { } } +// FIXME #13642 (these benchmarks should be in another place) /// Completely miscellaneous language-construct benchmarks. #[cfg(test)] mod bench { |
