diff options
| author | Jorge Aparicio <japaricious@gmail.com> | 2014-12-06 12:11:15 -0500 |
|---|---|---|
| committer | Jorge Aparicio <japaricious@gmail.com> | 2014-12-13 17:03:46 -0500 |
| commit | f56f9728e626886a89be852e642b84be7be36ab8 (patch) | |
| tree | 93d4f6fa46d1cfc9eb8ad6ccc08a6c5911cee1cf /src | |
| parent | c7b6eb38ff14b7225b7ccb86f9a2080fdba4a3e0 (diff) | |
libcore: use unboxed closures in `slice::raw` free functions
Diffstat (limited to 'src')
| -rw-r--r-- | src/libcore/slice.rs | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs index af150994765..27a4328ba80 100644 --- a/src/libcore/slice.rs +++ b/src/libcore/slice.rs @@ -1725,6 +1725,7 @@ pub mod raw { use mem::transmute; use ptr::RawPtr; use raw::Slice; + use ops::FnOnce; use option::Option; use option::Option::{None, Some}; @@ -1732,8 +1733,9 @@ pub mod raw { /// not bytes). #[inline] #[deprecated = "renamed to slice::from_raw_buf"] - pub unsafe fn buf_as_slice<T,U>(p: *const T, len: uint, f: |v: &[T]| -> U) - -> U { + pub unsafe fn buf_as_slice<T, U, F>(p: *const T, len: uint, f: F) -> U where + F: FnOnce(&[T]) -> U, + { f(transmute(Slice { data: p, len: len @@ -1744,12 +1746,9 @@ pub mod raw { /// not bytes). #[inline] #[deprecated = "renamed to slice::from_raw_mut_buf"] - pub unsafe fn mut_buf_as_slice<T, - U>( - p: *mut T, - len: uint, - f: |v: &mut [T]| -> U) - -> U { + pub unsafe fn mut_buf_as_slice<T, U, F>(p: *mut T, len: uint, f: F) -> U where + F: FnOnce(&mut [T]) -> U, + { f(transmute(Slice { data: p as *const T, len: len |
