Skip to content

Commit bb3a41a

Browse files
committed
---
yaml --- r: 64185 b: refs/heads/snap-stage3 c: 9ee5ce2 h: refs/heads/master i: 64183: 876d78a v: v3
1 parent 6a1166d commit bb3a41a

File tree

4 files changed

+57
-33
lines changed

4 files changed

+57
-33
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 3cb3d754a5bb1a6b22ab3a30d01a7f950127fe61
4+
refs/heads/snap-stage3: 9ee5ce221501cbafd8540586ec2904063b4448d6
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/libstd/cast.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
use sys;
1414
use unstable::intrinsics;
1515

16-
/// Casts the value at `src` to U. The two types must have the same length.
1716
/// Casts the value at `src` to U. The two types must have the same length.
1817
#[cfg(target_word_size = "32")]
1918
#[inline]

branches/snap-stage3/src/libstd/rand.rs

Lines changed: 19 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ distributions like normal and exponential.
2222
# Examples
2323
2424
~~~ {.rust}
25-
use std::rand;
26-
use std::rand::RngUtil;
25+
use core::rand::RngUtil;
2726
2827
fn main() {
2928
let mut rng = rand::rng();
@@ -34,8 +33,6 @@ fn main() {
3433
~~~
3534
3635
~~~ {.rust}
37-
use std::rand;
38-
3936
fn main () {
4037
let tuple_ptr = rand::random::<~(f64, char)>();
4138
println(fmt!("%?", tuple_ptr))
@@ -295,11 +292,10 @@ pub trait RngUtil {
295292
*
296293
* ~~~ {.rust}
297294
*
298-
* use std::rand;
299-
* use std::rand::RngUtil;
295+
* use core::rand::RngUtil;
300296
*
301297
* fn main() {
302-
* let mut rng = rand::rng();
298+
* rng = rand::rng();
303299
* println(fmt!("%b",rng.gen_weighted_bool(3)));
304300
* }
305301
* ~~~
@@ -312,11 +308,10 @@ pub trait RngUtil {
312308
*
313309
* ~~~ {.rust}
314310
*
315-
* use std::rand;
316-
* use std::rand::RngUtil;
311+
* use core::rand::RngUtil;
317312
*
318313
* fn main() {
319-
* let mut rng = rand::rng();
314+
* rng = rand::rng();
320315
* println(rng.gen_str(8));
321316
* }
322317
* ~~~
@@ -329,11 +324,10 @@ pub trait RngUtil {
329324
*
330325
* ~~~ {.rust}
331326
*
332-
* use std::rand;
333-
* use std::rand::RngUtil;
327+
* use core::rand::RngUtil;
334328
*
335329
* fn main() {
336-
* let mut rng = rand::rng();
330+
* rng = rand::rng();
337331
* println(fmt!("%?",rng.gen_bytes(8)));
338332
* }
339333
* ~~~
@@ -346,11 +340,10 @@ pub trait RngUtil {
346340
*
347341
* ~~~ {.rust}
348342
*
349-
* use std::rand;
350-
* use std::rand::RngUtil;
343+
* use core::rand::RngUtil;
351344
*
352345
* fn main() {
353-
* let mut rng = rand::rng();
346+
* rng = rand::rng();
354347
* println(fmt!("%d",rng.choose([1,2,4,8,16,32])));
355348
* }
356349
* ~~~
@@ -366,11 +359,10 @@ pub trait RngUtil {
366359
*
367360
* ~~~ {.rust}
368361
*
369-
* use std::rand;
370-
* use std::rand::RngUtil;
362+
* use core::rand::RngUtil;
371363
*
372364
* fn main() {
373-
* let mut rng = rand::rng();
365+
* rng = rand::rng();
374366
* let x = [rand::Weighted {weight: 4, item: 'a'},
375367
* rand::Weighted {weight: 2, item: 'b'},
376368
* rand::Weighted {weight: 2, item: 'c'}];
@@ -387,11 +379,10 @@ pub trait RngUtil {
387379
*
388380
* ~~~ {.rust}
389381
*
390-
* use std::rand;
391-
* use std::rand::RngUtil;
382+
* use core::rand::RngUtil;
392383
*
393384
* fn main() {
394-
* let mut rng = rand::rng();
385+
* rng = rand::rng();
395386
* let x = [rand::Weighted {weight: 4, item: 'a'},
396387
* rand::Weighted {weight: 2, item: 'b'},
397388
* rand::Weighted {weight: 2, item: 'c'}];
@@ -409,11 +400,10 @@ pub trait RngUtil {
409400
*
410401
* ~~~ {.rust}
411402
*
412-
* use std::rand;
413-
* use std::rand::RngUtil;
403+
* use core::rand::RngUtil;
414404
*
415405
* fn main() {
416-
* let mut rng = rand::rng();
406+
* rng = rand::rng();
417407
* let x = [rand::Weighted {weight: 4, item: 'a'},
418408
* rand::Weighted {weight: 2, item: 'b'},
419409
* rand::Weighted {weight: 2, item: 'c'}];
@@ -429,11 +419,10 @@ pub trait RngUtil {
429419
*
430420
* ~~~ {.rust}
431421
*
432-
* use std::rand;
433-
* use std::rand::RngUtil;
422+
* use core::rand::RngUtil;
434423
*
435424
* fn main() {
436-
* let mut rng = rand::rng();
425+
* rng = rand::rng();
437426
* println(fmt!("%?",rng.shuffle([1,2,3])));
438427
* }
439428
* ~~~
@@ -446,11 +435,10 @@ pub trait RngUtil {
446435
*
447436
* ~~~ {.rust}
448437
*
449-
* use std::rand;
450-
* use std::rand::RngUtil;
438+
* use core::rand::RngUtil;
451439
*
452440
* fn main() {
453-
* let mut rng = rand::rng();
441+
* rng = rand::rng();
454442
* let mut y = [1,2,3];
455443
* rng.shuffle_mut(y);
456444
* println(fmt!("%?",y));

branches/snap-stage3/src/libstd/vec.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1671,6 +1671,15 @@ pub trait MutableVector<'self, T> {
16711671

16721672
fn swap(self, a: uint, b: uint);
16731673

1674+
/**
1675+
* Divides one `&mut` into two. The first will
1676+
* contain all indices from `0..mid` (excluding the index `mid`
1677+
* itself) and the second will contain all indices from
1678+
* `mid..len` (excluding the index `len` itself).
1679+
*/
1680+
fn mut_split(self, mid: uint) -> (&'self mut [T],
1681+
&'self mut [T]);
1682+
16741683
fn reverse(self);
16751684

16761685
/**
@@ -1708,6 +1717,15 @@ impl<'self,T> MutableVector<'self, T> for &'self mut [T] {
17081717
}
17091718
}
17101719

1720+
#[inline]
1721+
fn mut_split(self, mid: uint) -> (&'self mut [T], &'self mut [T]) {
1722+
unsafe {
1723+
let len = self.len();
1724+
let self2: &'self mut [T] = cast::transmute_copy(&self);
1725+
(self.mut_slice(0, mid), self2.mut_slice(mid, len))
1726+
}
1727+
}
1728+
17111729
#[inline]
17121730
fn mut_iter(self) -> VecMutIterator<'self, T> {
17131731
unsafe {
@@ -3355,4 +3373,23 @@ mod tests {
33553373
v.push(1);
33563374
v.push(2);
33573375
}
3376+
3377+
#[test]
3378+
fn test_mut_split() {
3379+
let mut values = [1u8,2,3,4,5];
3380+
{
3381+
let (left, right) = values.mut_split(2);
3382+
assert_eq!(left.slice(0, left.len()), [1, 2]);
3383+
for left.mut_iter().advance |p| {
3384+
*p += 1;
3385+
}
3386+
3387+
assert_eq!(right.slice(0, right.len()), [3, 4, 5]);
3388+
for right.mut_iter().advance |p| {
3389+
*p += 2;
3390+
}
3391+
}
3392+
3393+
assert_eq!(values, [2, 3, 5, 6, 7]);
3394+
}
33583395
}

0 commit comments

Comments
 (0)