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