Repository: nushell/nushell
File: crates/nu-command/src/filters/drop/nth.rs (Rust)

Code before:
        let head = call.head;
        let metadata = input.metadata();

        let args: Vec<Value> = call.rest(engine_state, stack, 0)?;
        if args.is_empty() {
            return Ok(input);
        }

        let (rows_to_drop, min_unbounded_start) = get_rows_to_drop(&args, head)?;

        let input = if let Some(cutoff) = min_unbounded_start {
            input
                .into_iter()
                .take(cutoff)
                .into_pipeline_data_with_metadata(
                    head,
                    engine_state.signals().clone(),
                    metadata.clone(),
                )
        } else {
            input
        };

        Ok(DropNthIterator {
            input: input.into_iter(),
            rows: rows_to_drop.into(),
            current: 0,
        }
        .into_pipeline_data_with_metadata(head, engine_state.signals().clone(), metadata))
    }
}

fn get_rows_to_drop(
    args: &[Value],
    head: Span,
) -> Result<(VecDeque<usize>, Option<usize>), ShellError> {
    let mut rows_to_drop = Vec::new();
    let mut min_unbounded_start: Option<usize> = None;

    for value in args {
        if let Ok(i) = value.as_int() {
            if i < 0 {
                return Err(ShellError::UnsupportedInput {
                    msg: "drop nth accepts only positive ints".into(),
                    input: "value originates from here".into(),
                    msg_span: head,
                    input_span: value.span(),
                });
            }
            rows_to_drop.push(i as usize);
        } else if let Ok(range) = value.as_range() {

Review comment (suggestion):
can you make the actual `rows` field in `DropNthIterator` a `VecDeque`, instead of just converting the `VecDeque` back into a `Vec` here? in addition to that, you can change `self.rows.remove(0);` to `self.rows.pop_front();` in `DropNthIterator::next` 

Code after:
        let head = call.head;
        let metadata = input.metadata();

        let args: Vec<Value> = call.rest(engine_state, stack, 0)?;
        if args.is_empty() {
            return Ok(input);
        }

        let (rows_to_drop, min_unbounded_start) = get_rows_to_drop(&args, head)?;

        let input = if let Some(cutoff) = min_unbounded_start {
            input
                .into_iter()
                .take(cutoff)
                .into_pipeline_data_with_metadata(
                    head,
                    engine_state.signals().clone(),
                    metadata.clone(),
                )
        } else {
            input
        };

        Ok(DropNthIterator {
            input: input.into_iter(),
            rows: rows_to_drop,
            current: 0,
        }
        .into_pipeline_data_with_metadata(head, engine_state.signals().clone(), metadata))
    }
}

fn get_rows_to_drop(
    args: &[Value],
    head: Span,
) -> Result<(VecDeque<usize>, Option<usize>), ShellError> {
    let mut rows_to_drop = Vec::new();
    let mut min_unbounded_start: Option<usize> = None;

    for value in args {
        if let Ok(i) = value.as_int() {
            if i < 0 {
                return Err(ShellError::UnsupportedInput {
                    msg: "drop nth accepts only positive ints".into(),
                    input: "value originates from here".into(),
                    msg_span: head,
                    input_span: value.span(),
                });
            }
            rows_to_drop.push(i as usize);
        } else if let Ok(range) = value.as_range() {