compatible with old rust (#5974)

This commit is contained in:
WindSoilder 2022-07-07 07:22:45 +08:00 committed by GitHub
parent 8abf28093a
commit e0b4ab09eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 30 additions and 6 deletions

View File

@ -63,7 +63,11 @@ impl Command for BytesAdd {
) -> Result<PipelineData, ShellError> {
let added_data: Vec<u8> = call.req(engine_state, stack, 0)?;
let column_paths: Vec<CellPath> = call.rest(engine_state, stack, 1)?;
let column_paths = (!column_paths.is_empty()).then_some(column_paths);
let column_paths = if column_paths.is_empty() {
None
} else {
Some(column_paths)
};
let index: Option<usize> = call.get_flag(engine_state, stack, "index")?;
let end = call.has_flag("end");

View File

@ -54,7 +54,11 @@ impl Command for BytesEndsWith {
) -> Result<PipelineData, ShellError> {
let pattern: Vec<u8> = call.req(engine_state, stack, 0)?;
let column_paths: Vec<CellPath> = call.rest(engine_state, stack, 1)?;
let column_paths = (!column_paths.is_empty()).then_some(column_paths);
let column_paths = if column_paths.is_empty() {
None
} else {
Some(column_paths)
};
let arg = Arguments {
pattern,
column_paths,

View File

@ -50,7 +50,11 @@ impl Command for BytesLen {
input: PipelineData,
) -> Result<PipelineData, ShellError> {
let column_paths: Vec<CellPath> = call.rest(engine_state, stack, 1)?;
let column_paths = (!column_paths.is_empty()).then_some(column_paths);
let column_paths = if column_paths.is_empty() {
None
} else {
Some(column_paths)
};
let arg = Arguments { column_paths };
operate(length, arg, input, call.head, engine_state.ctrlc.clone())
}

View File

@ -56,7 +56,11 @@ impl Command for BytesReplace {
input: PipelineData,
) -> Result<PipelineData, ShellError> {
let column_paths: Vec<CellPath> = call.rest(engine_state, stack, 2)?;
let column_paths = (!column_paths.is_empty()).then_some(column_paths);
let column_paths = if column_paths.is_empty() {
None
} else {
Some(column_paths)
};
let find = call.req::<Vec<u8>>(engine_state, stack, 0)?;
if find.is_empty() {
return Err(ShellError::UnsupportedInput(

View File

@ -51,7 +51,11 @@ impl Command for BytesReverse {
input: PipelineData,
) -> Result<PipelineData, ShellError> {
let column_paths: Vec<CellPath> = call.rest(engine_state, stack, 0)?;
let column_paths = (!column_paths.is_empty()).then_some(column_paths);
let column_paths = if column_paths.is_empty() {
None
} else {
Some(column_paths)
};
let arg = Arguments { column_paths };
operate(reverse, arg, input, call.head, engine_state.ctrlc.clone())
}

View File

@ -54,7 +54,11 @@ impl Command for BytesStartsWith {
) -> Result<PipelineData, ShellError> {
let pattern: Vec<u8> = call.req(engine_state, stack, 0)?;
let column_paths: Vec<CellPath> = call.rest(engine_state, stack, 1)?;
let column_paths = (!column_paths.is_empty()).then_some(column_paths);
let column_paths = if column_paths.is_empty() {
None
} else {
Some(column_paths)
};
let arg = Arguments {
pattern,
column_paths,