Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modifies PartialEq for Violation #208

Merged
merged 8 commits into from
Mar 11, 2024
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
4 changes: 2 additions & 2 deletions ion-schema-tests-runner/src/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ fn generate_test_cases_for_file(ctx: Context) -> TokenStream {
// get the schema content from given schema file path
let ion_content = fs::read(ctx.current_dir.as_path())
.unwrap_or_else(|e| panic!("Unable to read {path_string} – {e}"));
let schema_content = Element::read_all(&ion_content)
.unwrap_or_else(|e| panic!("Error in {path_string} – {e:?}"));
let schema_content =
Element::read_all(ion_content).unwrap_or_else(|e| panic!("Error in {path_string} – {e:?}"));

let isl_version = find_isl_version(&schema_content);

Expand Down
2 changes: 1 addition & 1 deletion ion-schema/examples/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ fn validate(command_args: &ArgMatches) -> IonSchemaResult<()> {
// Extract Ion value provided by user
let input_file = command_args.value_of("input").unwrap();
let value = fs::read(input_file).expect("Can not load given ion file");
let owned_elements = Element::read_all(&value).expect("parsing failed unexpectedly");
let owned_elements = Element::read_all(value).expect("parsing failed unexpectedly");

// Set up authorities vector
let mut document_authorities: Vec<Box<dyn DocumentAuthority>> = vec![];
Expand Down
8 changes: 6 additions & 2 deletions ion-schema/src/ion_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::fmt;
use std::fmt::{Debug, Formatter};

/// Represents a single element in Ion Path which is either an index value or a field name depending on its parent container type
#[derive(Clone, PartialEq, PartialOrd)]
#[derive(Clone, PartialEq, PartialOrd, Eq, Hash)]
pub enum IonPathElement {
Index(usize),
Field(String),
Expand Down Expand Up @@ -57,7 +57,7 @@ impl fmt::Display for IonPathElement {
/// ```ion
/// ( greetings 1 ) // here 1 represents the index of "hi" in the Ion list value
/// ```
#[derive(Default, Clone, PartialEq, PartialOrd)]
#[derive(Default, Clone, PartialEq, PartialOrd, Eq, Hash)]
pub struct IonPath {
ion_path_elements: Vec<IonPathElement>,
}
Expand All @@ -70,6 +70,10 @@ impl IonPath {
pub fn pop(&mut self) -> Option<IonPathElement> {
self.ion_path_elements.pop()
}

pub(crate) fn new(ion_path_elements: Vec<IonPathElement>) -> Self {
Self { ion_path_elements }
}
}

impl From<IonPath> for Element {
Expand Down
4 changes: 2 additions & 2 deletions ion-schema/src/isl/isl_constraint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ pub mod v_1_0 {
{
IslConstraint::new(
IslVersion::V1_0,
IslConstraintValue::Fields(fields.map(|(s, t)| (s, t)).collect(), false),
IslConstraintValue::Fields(fields.collect(), false),
)
}

Expand Down Expand Up @@ -278,7 +278,7 @@ pub mod v_2_0 {
{
IslConstraint::new(
IslVersion::V2_0,
IslConstraintValue::Fields(fields.map(|(s, t)| (s, t)).collect(), false),
IslConstraintValue::Fields(fields.collect(), false),
)
}

Expand Down
Loading
Loading