Skip to content

Commit 627397b

Browse files
committed
---
yaml --- r: 90504 b: refs/heads/master c: ad20a78 h: refs/heads/master v: v3
1 parent 1e530ef commit 627397b

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 33b6bf4bc1456b670e134b7581d2e26b8c2cff6c
2+
refs/heads/master: ad20a78c548819b6671ee11eed7501e61429575a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a6d3e57dca68fde4effdda3e4ae2887aa535fcd6
55
refs/heads/try: b160761e35efcd1207112b3b782c06633cf441a8

trunk/src/libstd/vec.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2053,6 +2053,13 @@ pub trait MutableVector<'a, T> {
20532053
/// Unsafely sets the element in index to the value
20542054
unsafe fn unsafe_set(self, index: uint, val: T);
20552055

2056+
/**
2057+
* Unchecked vector index assignment. Does not drop the
2058+
* old value and hence is only suitable when the vector
2059+
* is newly allocated.
2060+
*/
2061+
unsafe fn init_elem(self, i: uint, val: T);
2062+
20562063
/// Similar to `as_imm_buf` but passing a `*mut T`
20572064
fn as_mut_buf<U>(self, f: |*mut T, uint| -> U) -> U;
20582065
}
@@ -2181,6 +2188,15 @@ impl<'a,T> MutableVector<'a, T> for &'a mut [T] {
21812188
*self.unsafe_mut_ref(index) = val;
21822189
}
21832190

2191+
#[inline]
2192+
unsafe fn init_elem(self, i: uint, val: T) {
2193+
let mut alloc = Some(val);
2194+
self.as_mut_buf(|p, _len| {
2195+
intrinsics::move_val_init(&mut(*ptr::mut_offset(p, i as int)),
2196+
alloc.take_unwrap());
2197+
})
2198+
}
2199+
21842200
#[inline]
21852201
fn as_mut_buf<U>(self, f: |*mut T, uint| -> U) -> U {
21862202
let Slice{ data, len } = self.repr();
@@ -2221,9 +2237,7 @@ pub unsafe fn from_buf<T>(ptr: *T, elts: uint) -> ~[T] {
22212237
/// Unsafe operations
22222238
pub mod raw {
22232239
use cast;
2224-
use option::Some;
22252240
use ptr;
2226-
use unstable::intrinsics;
22272241
use vec::{with_capacity, ImmutableVector, MutableVector};
22282242
use unstable::raw::Slice;
22292243

@@ -2257,20 +2271,6 @@ pub mod raw {
22572271
}))
22582272
}
22592273

2260-
/**
2261-
* Unchecked vector index assignment. Does not drop the
2262-
* old value and hence is only suitable when the vector
2263-
* is newly allocated.
2264-
*/
2265-
#[inline]
2266-
pub unsafe fn init_elem<T>(v: &mut [T], i: uint, val: T) {
2267-
let mut alloc = Some(val);
2268-
v.as_mut_buf(|p, _len| {
2269-
intrinsics::move_val_init(&mut(*ptr::mut_offset(p, i as int)),
2270-
alloc.take_unwrap());
2271-
})
2272-
}
2273-
22742274
/**
22752275
* Constructs a vector from an unsafe pointer to a buffer
22762276
*

0 commit comments

Comments
 (0)