Skip to content

Commit 9db1d35

Browse files
committed
collections: Deprecate shift/unshift
Use insert/remove instead.
1 parent 94e42c2 commit 9db1d35

File tree

8 files changed

+10
-8
lines changed

8 files changed

+10
-8
lines changed

src/compiletest/runtest.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1178,7 +1178,7 @@ fn make_run_args(config: &Config, props: &TestProps, testfile: &Path) ->
11781178
// Add the arguments in the run_flags directive
11791179
args.push_all_move(split_maybe_args(&props.run_flags));
11801180

1181-
let prog = args.shift().unwrap();
1181+
let prog = args.remove(0).unwrap();
11821182
return ProcArgs {
11831183
prog: prog,
11841184
args: args,

src/libcollections/vec.rs

+2
Original file line numberDiff line numberDiff line change
@@ -987,6 +987,7 @@ impl<T> Vec<T> {
987987
/// assert_eq!(vec, vec![4, 1, 2, 3]);
988988
/// ```
989989
#[inline]
990+
#[deprecated = "use insert(0, ...)"]
990991
pub fn unshift(&mut self, element: T) {
991992
self.insert(0, element)
992993
}
@@ -1007,6 +1008,7 @@ impl<T> Vec<T> {
10071008
/// assert_eq!(vec, vec![2, 3]);
10081009
/// ```
10091010
#[inline]
1011+
#[deprecated = "use remove(0)"]
10101012
pub fn shift(&mut self) -> Option<T> {
10111013
self.remove(0)
10121014
}

src/libregex/parse.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -998,7 +998,7 @@ fn concat_flatten(x: Ast, y: Ast) -> Ast {
998998
match (x, y) {
999999
(Cat(mut xs), Cat(ys)) => { xs.push_all_move(ys); Cat(xs) }
10001000
(Cat(mut xs), ast) => { xs.push(ast); Cat(xs) }
1001-
(ast, Cat(mut xs)) => { xs.unshift(ast); Cat(xs) }
1001+
(ast, Cat(mut xs)) => { xs.insert(0, ast); Cat(xs) }
10021002
(ast1, ast2) => Cat(vec!(ast1, ast2)),
10031003
}
10041004
}

src/librustdoc/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ fn rust_input(cratefile: &str, externs: core::Externs, matches: &getopts::Matche
361361
}
362362
if default_passes {
363363
for name in DEFAULT_PASSES.iter().rev() {
364-
passes.unshift(name.to_string());
364+
passes.insert(0, name.to_string());
365365
}
366366
}
367367

src/librustdoc/markdown.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ pub fn test(input: &str, libs: HashSet<Path>, externs: core::Externs,
136136

137137
let mut collector = Collector::new(input.to_string(), libs, externs, true);
138138
find_testable_code(input_str.as_slice(), &mut collector);
139-
test_args.unshift("rustdoctest".to_string());
139+
test_args.insert(0, "rustdoctest".to_string());
140140
testing::test_main(test_args.as_slice(), collector.tests);
141141
0
142142
}

src/librustdoc/test.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ pub fn run(input: &str,
9797
false);
9898
collector.fold_crate(krate);
9999

100-
test_args.unshift("rustdoctest".to_string());
100+
test_args.insert(0, "rustdoctest".to_string());
101101

102102
testing::test_main(test_args.as_slice(),
103103
collector.tests.move_iter().collect());

src/librustuv/access.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ impl<'a> Drop for Guard<'a> {
114114
mem::transmute(self.access.inner.get())
115115
};
116116

117-
match inner.queue.shift() {
117+
match inner.queue.remove(0) {
118118
// Here we have found a task that was waiting for access, and we
119119
// current have the "access lock" we need to relinquish access to
120120
// this sleeping task.

src/libterm/terminfo/parm.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -514,12 +514,12 @@ fn format(val: Param, op: FormatOp, flags: Flags) -> Result<Vec<u8> ,String> {
514514
FormatDigit => {
515515
if flags.space && !(s[0] == '-' as u8 ||
516516
s[0] == '+' as u8) {
517-
s.unshift(' ' as u8);
517+
s.insert(0, ' ' as u8);
518518
}
519519
}
520520
FormatOctal => {
521521
if flags.alternate && s[0] != '0' as u8 {
522-
s.unshift('0' as u8);
522+
s.insert(0, '0' as u8);
523523
}
524524
}
525525
FormatHex => {

0 commit comments

Comments
 (0)