mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 16:54:58 +02:00
Finish removing arg deserialization (#3552)
* WIP remove process * WIP * WIP * Finish removing arg deserialization
This commit is contained in:
@ -77,7 +77,7 @@ pub enum CompareValues {
|
||||
Decimals(BigDecimal, BigDecimal),
|
||||
String(String, String),
|
||||
Date(DateTime<FixedOffset>, DateTime<FixedOffset>),
|
||||
DateDuration(DateTime<FixedOffset>, BigInt),
|
||||
DateDuration(DateTime<FixedOffset>, i64),
|
||||
Booleans(bool, bool),
|
||||
}
|
||||
|
||||
@ -92,11 +92,9 @@ impl CompareValues {
|
||||
CompareValues::Date(left, right) => left.cmp(right),
|
||||
CompareValues::DateDuration(left, right) => {
|
||||
// FIXME: Not sure if I could do something better with the Span.
|
||||
let duration = Primitive::into_chrono_duration(
|
||||
Primitive::Duration(right.clone()),
|
||||
Span::unknown(),
|
||||
)
|
||||
.expect("Could not convert nushell Duration into chrono Duration.");
|
||||
let duration =
|
||||
Primitive::into_chrono_duration(Primitive::Duration(*right), Span::unknown())
|
||||
.expect("Could not convert nushell Duration into chrono Duration.");
|
||||
let right: DateTime<FixedOffset> = Utc::now()
|
||||
.checked_sub_signed(duration)
|
||||
.expect("Data overflow")
|
||||
@ -160,7 +158,7 @@ pub fn coerce_compare_primitive(
|
||||
(Nothing, Nothing) => CompareValues::Booleans(true, true),
|
||||
(String(left), String(right)) => CompareValues::String(left.clone(), right.clone()),
|
||||
(Date(left), Date(right)) => CompareValues::Date(*left, *right),
|
||||
(Date(left), Duration(right)) => CompareValues::DateDuration(*left, right.clone()),
|
||||
(Date(left), Duration(right)) => CompareValues::DateDuration(*left, *right),
|
||||
(Boolean(left), Boolean(right)) => CompareValues::Booleans(*left, *right),
|
||||
(Boolean(left), Nothing) => CompareValues::Booleans(*left, false),
|
||||
(Nothing, Boolean(right)) => CompareValues::Booleans(false, *right),
|
||||
|
@ -33,7 +33,7 @@ pub enum InlineShape {
|
||||
GlobPattern(String),
|
||||
Boolean(bool),
|
||||
Date(DateTime<FixedOffset>),
|
||||
Duration(BigInt),
|
||||
Duration(i64),
|
||||
FilePath(PathBuf),
|
||||
Binary(usize),
|
||||
|
||||
@ -94,7 +94,7 @@ impl InlineShape {
|
||||
Primitive::GlobPattern(pattern) => InlineShape::GlobPattern(pattern.clone()),
|
||||
Primitive::Boolean(boolean) => InlineShape::Boolean(*boolean),
|
||||
Primitive::Date(date) => InlineShape::Date(*date),
|
||||
Primitive::Duration(duration) => InlineShape::Duration(duration.clone()),
|
||||
Primitive::Duration(duration) => InlineShape::Duration(*duration),
|
||||
Primitive::FilePath(path) => InlineShape::FilePath(path.clone()),
|
||||
Primitive::Binary(b) => InlineShape::Binary(b.len()),
|
||||
Primitive::BeginningOfStream => InlineShape::BeginningOfStream,
|
||||
@ -304,10 +304,9 @@ impl PrettyDebug for FormatInlineShape {
|
||||
.to_owned(),
|
||||
),
|
||||
InlineShape::Date(date) => DbgDocBldr::primitive(nu_protocol::format_date(date)),
|
||||
InlineShape::Duration(duration) => DbgDocBldr::description(format_primitive(
|
||||
&Primitive::Duration(duration.clone()),
|
||||
None,
|
||||
)),
|
||||
InlineShape::Duration(duration) => {
|
||||
DbgDocBldr::description(format_primitive(&Primitive::Duration(*duration), None))
|
||||
}
|
||||
InlineShape::FilePath(path) => DbgDocBldr::primitive(path.display()),
|
||||
InlineShape::Binary(length) => {
|
||||
DbgDocBldr::opaque(format!("<binary: {} bytes>", length))
|
||||
|
@ -475,8 +475,13 @@ pub fn compute_values(
|
||||
if y.is_zero() {
|
||||
return Ok(zero_division_error());
|
||||
}
|
||||
|
||||
let y = y.as_bigint_and_exponent();
|
||||
Ok(x / y.0)
|
||||
let z = y.0.to_i64();
|
||||
match z {
|
||||
Some(z) => Ok(x / z),
|
||||
None => Err((left.type_name(), right.type_name())),
|
||||
}
|
||||
}
|
||||
_ => Err((left.type_name(), right.type_name())),
|
||||
}?;
|
||||
|
Reference in New Issue
Block a user