collections: Deprecate shift/unshift
Use insert/remove instead.
This commit is contained in:
parent
94e42c2d89
commit
9db1d35687
@ -1178,7 +1178,7 @@ fn make_run_args(config: &Config, props: &TestProps, testfile: &Path) ->
|
||||
// Add the arguments in the run_flags directive
|
||||
args.push_all_move(split_maybe_args(&props.run_flags));
|
||||
|
||||
let prog = args.shift().unwrap();
|
||||
let prog = args.remove(0).unwrap();
|
||||
return ProcArgs {
|
||||
prog: prog,
|
||||
args: args,
|
||||
|
@ -987,6 +987,7 @@ pub fn swap_remove(&mut self, index: uint) -> Option<T> {
|
||||
/// assert_eq!(vec, vec![4, 1, 2, 3]);
|
||||
/// ```
|
||||
#[inline]
|
||||
#[deprecated = "use insert(0, ...)"]
|
||||
pub fn unshift(&mut self, element: T) {
|
||||
self.insert(0, element)
|
||||
}
|
||||
@ -1007,6 +1008,7 @@ pub fn unshift(&mut self, element: T) {
|
||||
/// assert_eq!(vec, vec![2, 3]);
|
||||
/// ```
|
||||
#[inline]
|
||||
#[deprecated = "use remove(0)"]
|
||||
pub fn shift(&mut self) -> Option<T> {
|
||||
self.remove(0)
|
||||
}
|
||||
|
@ -998,7 +998,7 @@ fn concat_flatten(x: Ast, y: Ast) -> Ast {
|
||||
match (x, y) {
|
||||
(Cat(mut xs), Cat(ys)) => { xs.push_all_move(ys); Cat(xs) }
|
||||
(Cat(mut xs), ast) => { xs.push(ast); Cat(xs) }
|
||||
(ast, Cat(mut xs)) => { xs.unshift(ast); Cat(xs) }
|
||||
(ast, Cat(mut xs)) => { xs.insert(0, ast); Cat(xs) }
|
||||
(ast1, ast2) => Cat(vec!(ast1, ast2)),
|
||||
}
|
||||
}
|
||||
|
@ -361,7 +361,7 @@ fn rust_input(cratefile: &str, externs: core::Externs, matches: &getopts::Matche
|
||||
}
|
||||
if default_passes {
|
||||
for name in DEFAULT_PASSES.iter().rev() {
|
||||
passes.unshift(name.to_string());
|
||||
passes.insert(0, name.to_string());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -136,7 +136,7 @@ pub fn test(input: &str, libs: HashSet<Path>, externs: core::Externs,
|
||||
|
||||
let mut collector = Collector::new(input.to_string(), libs, externs, true);
|
||||
find_testable_code(input_str.as_slice(), &mut collector);
|
||||
test_args.unshift("rustdoctest".to_string());
|
||||
test_args.insert(0, "rustdoctest".to_string());
|
||||
testing::test_main(test_args.as_slice(), collector.tests);
|
||||
0
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ pub fn run(input: &str,
|
||||
false);
|
||||
collector.fold_crate(krate);
|
||||
|
||||
test_args.unshift("rustdoctest".to_string());
|
||||
test_args.insert(0, "rustdoctest".to_string());
|
||||
|
||||
testing::test_main(test_args.as_slice(),
|
||||
collector.tests.move_iter().collect());
|
||||
|
@ -114,7 +114,7 @@ fn drop(&mut self) {
|
||||
mem::transmute(self.access.inner.get())
|
||||
};
|
||||
|
||||
match inner.queue.shift() {
|
||||
match inner.queue.remove(0) {
|
||||
// Here we have found a task that was waiting for access, and we
|
||||
// current have the "access lock" we need to relinquish access to
|
||||
// this sleeping task.
|
||||
|
@ -514,12 +514,12 @@ fn format(val: Param, op: FormatOp, flags: Flags) -> Result<Vec<u8> ,String> {
|
||||
FormatDigit => {
|
||||
if flags.space && !(s[0] == '-' as u8 ||
|
||||
s[0] == '+' as u8) {
|
||||
s.unshift(' ' as u8);
|
||||
s.insert(0, ' ' as u8);
|
||||
}
|
||||
}
|
||||
FormatOctal => {
|
||||
if flags.alternate && s[0] != '0' as u8 {
|
||||
s.unshift('0' as u8);
|
||||
s.insert(0, '0' as u8);
|
||||
}
|
||||
}
|
||||
FormatHex => {
|
||||
|
Loading…
Reference in New Issue
Block a user