mirror of
https://github.com/nushell/nushell.git
synced 2025-08-23 19:05:45 +02:00
refactor: ensure range is bounded (#15429)
No linked issue, it's a follow-up of 2 PRs I recently made to improve some math commands. (#15319) # Description Small refactor to simplify the code. It was suggested in the comments of my previous PR. # User-Facing Changes None # Tests + Formatting Tests, fmt and clippy OK # After Submitting Nothing more required
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
use crate::math::utils::ensure_bounded;
|
||||
use nu_engine::command_prelude::*;
|
||||
use nu_protocol::Range;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct MathSqrt;
|
||||
@@ -56,10 +55,7 @@ impl Command for MathSqrt {
|
||||
..,
|
||||
) = input
|
||||
{
|
||||
match &**val {
|
||||
Range::IntRange(range) => ensure_bounded(range.end(), internal_span, head)?,
|
||||
Range::FloatRange(range) => ensure_bounded(range.end(), internal_span, head)?,
|
||||
}
|
||||
ensure_bounded(val.as_ref(), internal_span, head)?;
|
||||
}
|
||||
input.map(move |value| operate(value, head), engine_state.signals())
|
||||
}
|
||||
@@ -83,10 +79,7 @@ impl Command for MathSqrt {
|
||||
..,
|
||||
) = input
|
||||
{
|
||||
match &**val {
|
||||
Range::IntRange(range) => ensure_bounded(range.end(), internal_span, head)?,
|
||||
Range::FloatRange(range) => ensure_bounded(range.end(), internal_span, head)?,
|
||||
}
|
||||
ensure_bounded(val.as_ref(), internal_span, head)?;
|
||||
}
|
||||
input.map(
|
||||
move |value| operate(value, head),
|
||||
|
Reference in New Issue
Block a user