From e0b4ab09eb898fa4f62d6162f6bf07a40a2c5ec3 Mon Sep 17 00:00:00 2001 From: WindSoilder Date: Thu, 7 Jul 2022 07:22:45 +0800 Subject: [PATCH] compatible with old rust (#5974) --- crates/nu-command/src/bytes/add.rs | 6 +++++- crates/nu-command/src/bytes/ends_with.rs | 6 +++++- crates/nu-command/src/bytes/length.rs | 6 +++++- crates/nu-command/src/bytes/replace.rs | 6 +++++- crates/nu-command/src/bytes/reverse.rs | 6 +++++- crates/nu-command/src/bytes/starts_with.rs | 6 +++++- 6 files changed, 30 insertions(+), 6 deletions(-) diff --git a/crates/nu-command/src/bytes/add.rs b/crates/nu-command/src/bytes/add.rs index 1a4ed3ac14..ff1bda62bf 100644 --- a/crates/nu-command/src/bytes/add.rs +++ b/crates/nu-command/src/bytes/add.rs @@ -63,7 +63,11 @@ impl Command for BytesAdd { ) -> Result { let added_data: Vec = call.req(engine_state, stack, 0)?; let column_paths: Vec = 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 = call.get_flag(engine_state, stack, "index")?; let end = call.has_flag("end"); diff --git a/crates/nu-command/src/bytes/ends_with.rs b/crates/nu-command/src/bytes/ends_with.rs index 3f96bbb2e5..6832c4a056 100644 --- a/crates/nu-command/src/bytes/ends_with.rs +++ b/crates/nu-command/src/bytes/ends_with.rs @@ -54,7 +54,11 @@ impl Command for BytesEndsWith { ) -> Result { let pattern: Vec = call.req(engine_state, stack, 0)?; let column_paths: Vec = 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, diff --git a/crates/nu-command/src/bytes/length.rs b/crates/nu-command/src/bytes/length.rs index 1283158c88..9e8dbb162e 100644 --- a/crates/nu-command/src/bytes/length.rs +++ b/crates/nu-command/src/bytes/length.rs @@ -50,7 +50,11 @@ impl Command for BytesLen { input: PipelineData, ) -> Result { let column_paths: Vec = 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()) } diff --git a/crates/nu-command/src/bytes/replace.rs b/crates/nu-command/src/bytes/replace.rs index e719f834bc..69702915b7 100644 --- a/crates/nu-command/src/bytes/replace.rs +++ b/crates/nu-command/src/bytes/replace.rs @@ -56,7 +56,11 @@ impl Command for BytesReplace { input: PipelineData, ) -> Result { let column_paths: Vec = 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::>(engine_state, stack, 0)?; if find.is_empty() { return Err(ShellError::UnsupportedInput( diff --git a/crates/nu-command/src/bytes/reverse.rs b/crates/nu-command/src/bytes/reverse.rs index 6f554a7ec6..977183378c 100644 --- a/crates/nu-command/src/bytes/reverse.rs +++ b/crates/nu-command/src/bytes/reverse.rs @@ -51,7 +51,11 @@ impl Command for BytesReverse { input: PipelineData, ) -> Result { let column_paths: Vec = 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()) } diff --git a/crates/nu-command/src/bytes/starts_with.rs b/crates/nu-command/src/bytes/starts_with.rs index a7d6391eac..a022530a23 100644 --- a/crates/nu-command/src/bytes/starts_with.rs +++ b/crates/nu-command/src/bytes/starts_with.rs @@ -54,7 +54,11 @@ impl Command for BytesStartsWith { ) -> Result { let pattern: Vec = call.req(engine_state, stack, 0)?; let column_paths: Vec = 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,