Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ flate2 = "1.0"
infer = "0.15.0"
# ion-rs version must be pinned because we are using experimental features
# See https://github.com/amazon-ion/ion-cli/issues/155
ion-rs = { version = "1.0.0-rc.12", features = ["experimental", "experimental-ion-hash", "experimental-tooling-apis"] }
ion-schema = { version = "0.16.0" }
ion-rs = { version = "=1.0.0", features = ["experimental", "experimental-ion-hash", "experimental-tooling-apis"] }
ion-schema = { version = "0.16.1" }
tempfile = "3.2.0"
lowcharts = "0.5.8"
serde = { version = "1.0.163", features = ["derive"] }
Expand Down
15 changes: 8 additions & 7 deletions src/bin/ion/commands/jq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,10 @@ fn filter_and_print(
/// Wraps an `Element` so we can:
/// 1. Define implementations of common traits like `Ord` and `Eq` without `Element` itself needing to.
/// 2. Keep all logic related to `jq` behavior in one place.
#[derive(Clone, Eq, Debug)]
#[derive(Clone, Debug)]
struct JaqElement(Element);

impl Eq for JaqElement {}
//TODO: move to sibling module so that people can't construct this and have to go through 'from'
// this will allow consistent construction/transformation rules e.g. field deduplication

Expand Down Expand Up @@ -212,8 +214,7 @@ impl FromIterator<Self> for JaqElement {

impl PartialEq<Self> for JaqElement {
fn eq(&self, other: &Self) -> bool {
// TODO: Should this use IonData::eq instead?
self.0.eq(&other.0)
IonData::from(&self.0).eq(&IonData::from(&other.0))
}
}

Expand Down Expand Up @@ -295,7 +296,7 @@ impl Add for JaqElement {
(Struct(a), Struct(b)) => a.clone_builder().with_fields(b.fields()).build().into(),

// Number types, only lossless operations
(Int(a), Int(b)) => (a + b).into(),
(Int(a), Int(b)) => a.add(b).into(),
(Float(a), Float(b)) => a.add(b).into(),
(Decimal(a), Decimal(b)) => a.add(b).into(),
(Decimal(a), Int(b)) | (Int(b), Decimal(a)) => a.add(b).into(),
Expand Down Expand Up @@ -337,7 +338,7 @@ impl Sub for JaqElement {
(SExp(a), SExp(b)) => ion_rs::SExp::from_iter(remove_elements(a, &b)).into(),

// Number types, only lossless operations
(Int(a), Int(b)) => (a + -b).into(), //TODO: use bare - with ion-rs > rc.11
(Int(a), Int(b)) => a.add(b.neg()).into(),
(Float(a), Float(b)) => a.sub(b).into(),
(Decimal(a), Decimal(b)) => DecimalMath::sub(a, b).into(),
(Decimal(a), Int(b)) => DecimalMath::sub(a, b).into(),
Expand Down Expand Up @@ -490,7 +491,7 @@ impl Neg for JaqElement {

let elt: Element = match val {
// Only number types can be negated
Int(a) => (-a).into(),
Int(a) => a.neg().into(),
Float(a) => (-a).into(),
Decimal(a) => (-a.into_big_decimal()).into_decimal().into(),

Expand Down Expand Up @@ -672,7 +673,7 @@ impl jaq_std::ValT for JaqElement {
pub(crate) mod ion_math {
use bigdecimal::num_bigint::BigInt;
use bigdecimal::{BigDecimal, ToPrimitive};
use ion_rs::decimal::coefficient::Sign;
use ion_rs::decimal::Sign;
use ion_rs::{Decimal, Int, Value};

/// We can't provide math traits for Decimal directly, so we have a helper trait
Expand Down
12 changes: 9 additions & 3 deletions src/bin/ion/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@ use anyhow::Result;
use anyhow::{bail, Context};
use clap::builder::ValueParser;
use clap::{crate_authors, crate_version, Arg, ArgAction, ArgMatches, Command as ClapCommand};
use ion_rs::Format::Binary;
use ion_rs::{Format, IonEncoding, TextFormat};
use ion_rs::{IonEncoding, TextFormat};
use std::fs::File;

/// Local replacement for the `Format` enum that was removed from ion-rs in 1.0.0.
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub(crate) enum Format {
Text(TextFormat),
Binary,
}
use std::io::IsTerminal;
use std::io::Write;
use termcolor::{ColorChoice, StandardStream, StandardStreamLock};
Expand Down Expand Up @@ -278,7 +284,7 @@ impl CommandIo<'_> {
(unrecognized, _) => bail!("unrecognized Ion version '{unrecognized}'"),
};

let color = if format == Binary {
let color = if format == Format::Binary {
ColorChoice::Never
} else {
let default_use_color = std::io::stdout().is_terminal();
Expand Down
3 changes: 2 additions & 1 deletion src/bin/ion/output.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::commands::Format;
use crate::file_writer::FileWriter;
use anyhow::bail;
use ion_rs::{v1_0, v1_1, Format, IonEncoding, Writer};
use ion_rs::{v1_0, v1_1, IonEncoding, Writer};
use ion_rs::{IonResult, WriteAsIon};
use std::io;
use std::io::Write;
Expand Down
1 change: 1 addition & 0 deletions src/bin/ion/transcribe.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::commands::Format;
use anyhow::{bail, Result};
use ion_rs::*;
use std::io::Write;
Expand Down
Loading