Skip to content

Commit 4b61b96

Browse files
committed
---
yaml --- r: 96751 b: refs/heads/dist-snap c: ad20a78 h: refs/heads/master i: 96749: e2ead01 96747: 71e0dd6 96743: 557e92d 96735: a2154c1 v: v3
1 parent ed9340a commit 4b61b96

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
@@ -6,7 +6,7 @@ refs/heads/try: c274a6888410ce3e357e014568b43310ed787d36
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/dist-snap: 33b6bf4bc1456b670e134b7581d2e26b8c2cff6c
9+
refs/heads/dist-snap: ad20a78c548819b6671ee11eed7501e61429575a
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/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)