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

Support for parsing a list of schemas which may have cross dependencies #173

Merged
merged 12 commits into from
Jan 29, 2021
Prev Previous commit
Next Next commit
Small formatting fixes
batconjurer committed Jan 29, 2021
commit 38382aa67997d0ca179ec802357c708ba8040e98
6 changes: 4 additions & 2 deletions src/schema.rs
Original file line number Diff line number Diff line change
@@ -432,7 +432,7 @@ impl Schema {
let fullname = Name::parse(&inner)?.fullname(None);
let previous_value = input_schemas.insert(fullname.clone(), schema);
if previous_value.is_some() {
return Err(Error::NameCollision(fullname))
return Err(Error::NameCollision(fullname));
}
let _ = input_order.push(fullname);
} else {
@@ -481,7 +481,9 @@ impl Parser {

let mut parsed_schemas = Vec::with_capacity(self.parsed_schemas.len());
for name in self.input_order.drain(0..) {
let parsed = self.parsed_schemas.remove(&name)
let parsed = self
.parsed_schemas
.remove(&name)
.expect("One of the input schemas was unexpectedly not parsed");
parsed_schemas.push(parsed);
}
2 changes: 0 additions & 2 deletions tests/schema.rs
Original file line number Diff line number Diff line change
@@ -690,7 +690,6 @@ fn test_parse_list_with_cross_deps_basic() {
let schemas_first = Schema::parse_list(&schema_strs_first).expect("Test failed");
let schemas_second = Schema::parse_list(&schema_strs_second).expect("Test failed");


let parsed_1 = Schema::parse_str(&schema_str_1).expect("Test failed");
let parsed_2 = Schema::parse_str(&schema_composite).expect("Test failed");
assert_eq!(schemas_first, vec!(parsed_1.clone(), parsed_2.clone()));
@@ -736,7 +735,6 @@ fn test_parse_list_with_cross_deps_and_namespaces() {
let schemas_first = Schema::parse_list(&schema_strs_first).expect("Test failed");
let schemas_second = Schema::parse_list(&schema_strs_second).expect("Test failed");


let parsed_1 = Schema::parse_str(&schema_str_1).expect("Test failed");
let parsed_2 = Schema::parse_str(&schema_composite).expect("Test failed");
assert_eq!(schemas_first, vec!(parsed_1.clone(), parsed_2.clone()));