We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents e9a0db6 + c88ce30 commit 878a310Copy full SHA for 878a310
src/libcore/vec.rs
@@ -2145,6 +2145,20 @@ pub mod raw {
2145
f(*v)
2146
}
2147
2148
+ /**
2149
+ * Form a slice from a pointer and length (as a number of units,
2150
+ * not bytes).
2151
+ */
2152
+ #[inline(always)]
2153
+ pub unsafe fn mut_buf_as_slice<T,U>(p: *mut T,
2154
+ len: uint,
2155
+ f: &fn(v: &mut [T]) -> U) -> U {
2156
+ let pair = (p, len * sys::nonzero_size_of::<T>());
2157
+ let v : *(&blk/mut [T]) =
2158
+ ::cast::reinterpret_cast(&addr_of(&pair));
2159
+ f(*v)
2160
+ }
2161
+
2162
/**
2163
* Unchecked vector indexing.
2164
*/
0 commit comments