aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2022-04-24 00:33:26 -0600
committerMelody Horn <melody@boringcactus.com>2022-04-24 00:33:26 -0600
commit18bd24960b220a0467aee57b1f77952a694433f0 (patch)
tree28cd22f8ebacc0bb4ed5d8e41d5252774ab62b50
parent74b64c103302b3715ad4222782cf872405ac5463 (diff)
downloadkdl-schema-canon.tar.gz
kdl-schema-canon.zip
use `r#ref` instead of `ref_` as field nameHEADcanon
-rw-r--r--Cargo.toml4
-rw-r--r--src/lib.rs20
-rw-r--r--tests/ref-resolution.rs8
3 files changed, 15 insertions, 17 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 171e4bd..43bab4e 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,8 +13,8 @@ default = ["parse-knuffel"]
parse-knuffel = ["knuffel"]
[dependencies]
-knuffel = { version = "1.1.0", optional = true }
+knuffel = { version = "2.0.0", optional = true }
lazy_static = "1.4.0"
[dev-dependencies]
-miette = { version = "3.3.0", features = ["fancy"] }
+miette = { version = "4.4.0", features = ["fancy"] }
diff --git a/src/lib.rs b/src/lib.rs
index 5f915cf..65e3114 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -107,9 +107,7 @@ impl Schema {
/// # Errors
///
/// returns an error if knuffel can't parse the document as a Schema
- pub fn parse(
- schema_kdl: &str,
- ) -> Result<Self, knuffel::Error<impl knuffel::traits::ErrorSpan>> {
+ pub fn parse(schema_kdl: &str) -> Result<Self, knuffel::Error> {
knuffel::parse("<Schema::parse argument>", schema_kdl)
}
}
@@ -240,7 +238,7 @@ pub struct Node {
pub description: Option<String>,
/// KDL query from which to load node information instead of specifying it inline (allows for recursion)
#[cfg_attr(feature = "parse-knuffel", knuffel(property))]
- pub ref_: Option<String>,
+ pub r#ref: Option<String>,
/// minimum number of occurrences of this node
#[cfg_attr(feature = "parse-knuffel", knuffel(child, unwrap(argument)))]
pub min: Option<usize>,
@@ -301,7 +299,7 @@ impl Node {
impl BuildFromRef for Node {
fn ref_to(query: impl Into<String>) -> Self {
Self {
- ref_: Some(query.into()),
+ r#ref: Some(query.into()),
..Self::default()
}
}
@@ -322,7 +320,7 @@ pub struct Prop {
pub description: Option<String>,
/// KDL query from which to load property information instead of specifying it inline (allows for recursion)
#[cfg_attr(feature = "parse-knuffel", knuffel(property))]
- pub ref_: Option<String>,
+ pub r#ref: Option<String>,
/// whether or not this property is required
#[cfg_attr(feature = "parse-knuffel", knuffel(child))]
pub required: bool,
@@ -344,7 +342,7 @@ impl Prop {
impl BuildFromRef for Prop {
fn ref_to(query: impl Into<String>) -> Self {
Self {
- ref_: Some(query.into()),
+ r#ref: Some(query.into()),
..Self::default()
}
}
@@ -362,7 +360,7 @@ pub struct Value {
pub description: Option<String>,
/// KDL query from which to load value information instead of specifying it inline (allows for recursion)
#[cfg_attr(feature = "parse-knuffel", knuffel(property))]
- pub ref_: Option<String>,
+ pub r#ref: Option<String>,
/// minimum number of occurrences of this value
#[cfg_attr(feature = "parse-knuffel", knuffel(child, unwrap(argument)))]
pub min: Option<usize>,
@@ -387,7 +385,7 @@ impl Value {
impl BuildFromRef for Value {
fn ref_to(query: impl Into<String>) -> Self {
Self {
- ref_: Some(query.into()),
+ r#ref: Some(query.into()),
..Self::default()
}
}
@@ -405,7 +403,7 @@ pub struct Children {
pub description: Option<String>,
/// KDL query from which to load children information instead of specifying it inline (allows for recursion)
#[cfg_attr(feature = "parse-knuffel", knuffel(property))]
- pub ref_: Option<String>,
+ pub r#ref: Option<String>,
/// nodes which can appear as children
#[cfg_attr(feature = "parse-knuffel", knuffel(children(name = "node")))]
pub nodes: Vec<Node>,
@@ -438,7 +436,7 @@ impl Children {
impl BuildFromRef for Children {
fn ref_to(query: impl Into<String>) -> Self {
Self {
- ref_: Some(query.into()),
+ r#ref: Some(query.into()),
..Self::default()
}
}
diff --git a/tests/ref-resolution.rs b/tests/ref-resolution.rs
index e6bb648..df5ee9b 100644
--- a/tests/ref-resolution.rs
+++ b/tests/ref-resolution.rs
@@ -107,27 +107,27 @@ fn children_ref_malformed() {
#[test]
fn all_schema_schema_refs_resolve() {
fn all_refs_resolve(node: &Node) {
- if let Some(r#ref) = &node.ref_ {
+ if let Some(r#ref) = &node.r#ref {
SCHEMA_SCHEMA
.resolve_node_ref(r#ref)
.unwrap_or_else(|| panic!("node ref {} not found", r#ref));
} else {
for prop in &node.props {
- if let Some(r#ref) = &prop.ref_ {
+ if let Some(r#ref) = &prop.r#ref {
SCHEMA_SCHEMA
.resolve_prop_ref(r#ref)
.unwrap_or_else(|| panic!("prop ref {} not found", r#ref));
}
}
for value in &node.values {
- if let Some(r#ref) = &value.ref_ {
+ if let Some(r#ref) = &value.r#ref {
SCHEMA_SCHEMA
.resolve_value_ref(r#ref)
.unwrap_or_else(|| panic!("value ref {} not found", r#ref));
}
}
for children in &node.children {
- if let Some(r#ref) = &children.ref_ {
+ if let Some(r#ref) = &children.r#ref {
SCHEMA_SCHEMA
.resolve_children_ref(r#ref)
.unwrap_or_else(|| panic!("children ref {} not found", r#ref));