DRY for Language; prepare for factoring out language prerequisites

This commit is contained in:
Tony Garnock-Jones 2021-09-17 12:27:10 +02:00
parent ac8567731d
commit a91ee3977f
5 changed files with 200 additions and 42 deletions

View File

@ -114,6 +114,10 @@ impl<'b> BundleContext<'b> {
f(&mut m);
items.entry(mode).or_default().extend(m.extract());
}
pub fn language_struct_name(&self) -> &'static str {
"Language"
}
}
impl<'m, 'b> ModuleContext<'m, 'b> {
@ -189,7 +193,9 @@ impl<'m, 'b> ModuleContext<'m, 'b> {
}
pub fn language_base_type(&self) -> Item {
item(format!("{}::Language", self.bundle.config.fully_qualified_module_prefix))
item(format!("{}::{}",
self.bundle.config.fully_qualified_module_prefix,
self.bundle.language_struct_name()))
}
pub fn extract(&mut self) -> Vec<Item> {

View File

@ -260,16 +260,16 @@ pub fn compile(config: &CompilerConfig) -> io::Result<()> {
lines.push("#[allow(non_snake_case)]".to_owned());
lines.push(Formatter::to_string(item(seq![
"pub struct Language", anglebrackets!["N: preserves::value::NestedValue"], " ",
"pub struct ", b.language_struct_name(), anglebrackets!["N: preserves::value::NestedValue"], " ",
vertical(false, braces(b.literals.iter().map(
|(value, name)| item(format!("pub {}: N /* {:?} */", name, value))).collect()))
])));
lines.push("".to_owned());
lines.push(Formatter::to_string(item(seq![
"impl", anglebrackets!["N: preserves::value::NestedValue"],
" Default for Language<N> ", codeblock![
" Default for ", b.language_struct_name(), "<N> ", codeblock![
seq!["fn default() -> Self ", codeblock![
seq!["Language ", vertical(false, braces(b.literals.iter().map(|(value, name)| {
seq![b.language_struct_name(), " ", vertical(false, braces(b.literals.iter().map(|(value, name)| {
let bs = preserves::value::PackedWriter::encode_iovalue(&value).unwrap();
item(format!("{}: /* {:?} */ _support::decode_lit(&vec!{:?}).unwrap()",
name,

View File

@ -74,7 +74,11 @@ pub fn gen_definition_parser(m: &mut ModuleContext, n: &str, d: &Definition) {
}
}
item(seq!["impl<'a, _L: Copy + Into<&'a ", ctxt.m.language_type(), ">, ", ctxt.m.any_type(), ": preserves::value::NestedValue + 'a>",
item(seq!["impl",
anglebrackets![
"'a",
seq!["_L: Copy + Into<&'a ", ctxt.m.language_type(), ">"],
seq![ctxt.m.any_type(), ": preserves::value::NestedValue + 'a"]],
" _support::Parse", anglebrackets!["_L", ctxt.m.any_type()], " for ",
names::render_constructor(n), ty.generic_arg(ctxt.m), " ",
codeblock![

View File

@ -97,7 +97,11 @@ pub fn gen_definition_unparser(m: &mut ModuleContext, n: &str, d: &Definition) {
}
}
item(seq!["impl<'a, _L: Copy + Into<&'a ", ctxt.m.language_type(), ">, ", ctxt.m.any_type(), ": preserves::value::NestedValue + 'a>",
item(seq!["impl",
anglebrackets![
"'a",
seq!["_L: Copy + Into<&'a ", ctxt.m.language_type(), ">"],
seq![ctxt.m.any_type(), ": preserves::value::NestedValue + 'a"]],
" _support::Unparse", anglebrackets!["_L", ctxt.m.any_type()], " for ",
names::render_constructor(n), ty.generic_arg(ctxt.m), " ",
codeblock![

View File

@ -191,7 +191,11 @@ fn parse_atom_kind_symbol<
Ok(AtomKind::Symbol)
}
impl<'a, _L: Copy + Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Parse<_L, _Value> for AtomKind {
impl<
'a,
_L: Copy + Into<&'a crate::gen::Language<_Value>>,
_Value: preserves::value::NestedValue + 'a
> _support::Parse<_L, _Value> for AtomKind {
fn parse(_ctxt: _L, value: &_Value) -> std::result::Result<Self, _support::ParseError> {
if let Ok(r) = parse_atom_kind_boolean(_ctxt, value) { return Ok(r); }
if let Ok(r) = parse_atom_kind_float(_ctxt, value) { return Ok(r); }
@ -204,7 +208,11 @@ impl<'a, _L: Copy + Into<&'a crate::gen::Language<_Value>>, _Value: preserves::v
}
}
impl<'a, _L: Copy + Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Unparse<_L, _Value> for AtomKind {
impl<
'a,
_L: Copy + Into<&'a crate::gen::Language<_Value>>,
_Value: preserves::value::NestedValue + 'a
> _support::Unparse<_L, _Value> for AtomKind {
fn unparse(&self, _ctxt: _L) -> _Value {
match self {
AtomKind::Boolean => (&_ctxt.into().LIT_0_BOOLEAN).clone(),
@ -251,7 +259,11 @@ impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value
}
}
impl<'a, _L: Copy + Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Parse<_L, _Value> for Binding<_Value> {
impl<
'a,
_L: Copy + Into<&'a crate::gen::Language<_Value>>,
_Value: preserves::value::NestedValue + 'a
> _support::Parse<_L, _Value> for Binding<_Value> {
fn parse(_ctxt: _L, value: &_Value) -> std::result::Result<Self, _support::ParseError> {
let _tmp0 = value.value().to_record(None)?;
if _tmp0.label() != &_ctxt.into().LIT_7_NAMED { return Err(_support::ParseError::conformance_error("schema.Binding")); }
@ -263,7 +275,11 @@ impl<'a, _L: Copy + Into<&'a crate::gen::Language<_Value>>, _Value: preserves::v
}
}
impl<'a, _L: Copy + Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Unparse<_L, _Value> for Binding<_Value> {
impl<
'a,
_L: Copy + Into<&'a crate::gen::Language<_Value>>,
_Value: preserves::value::NestedValue + 'a
> _support::Unparse<_L, _Value> for Binding<_Value> {
fn unparse(&self, _ctxt: _L) -> _Value {
let Binding {name: _tmp0, pattern: _tmp1} = self;
{
@ -304,7 +320,11 @@ impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value
}
}
impl<'a, _L: Copy + Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Parse<_L, _Value> for Bundle<_Value> {
impl<
'a,
_L: Copy + Into<&'a crate::gen::Language<_Value>>,
_Value: preserves::value::NestedValue + 'a
> _support::Parse<_L, _Value> for Bundle<_Value> {
fn parse(_ctxt: _L, value: &_Value) -> std::result::Result<Self, _support::ParseError> {
let _tmp0 = value.value().to_record(None)?;
if _tmp0.label() != &_ctxt.into().LIT_8_BUNDLE { return Err(_support::ParseError::conformance_error("schema.Bundle")); }
@ -315,7 +335,11 @@ impl<'a, _L: Copy + Into<&'a crate::gen::Language<_Value>>, _Value: preserves::v
}
}
impl<'a, _L: Copy + Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Unparse<_L, _Value> for Bundle<_Value> {
impl<
'a,
_L: Copy + Into<&'a crate::gen::Language<_Value>>,
_Value: preserves::value::NestedValue + 'a
> _support::Unparse<_L, _Value> for Bundle<_Value> {
fn unparse(&self, _ctxt: _L) -> _Value {
let Bundle {modules: _tmp0} = self;
{
@ -525,7 +549,11 @@ fn parse_compound_pattern_dict<
Ok(CompoundPattern::Dict {entries: std::boxed::Box::new(_tmp2)})
}
impl<'a, _L: Copy + Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Parse<_L, _Value> for CompoundPattern<_Value> {
impl<
'a,
_L: Copy + Into<&'a crate::gen::Language<_Value>>,
_Value: preserves::value::NestedValue + 'a
> _support::Parse<_L, _Value> for CompoundPattern<_Value> {
fn parse(_ctxt: _L, value: &_Value) -> std::result::Result<Self, _support::ParseError> {
if let Ok(r) = parse_compound_pattern_rec(_ctxt, value) { return Ok(r); }
if let Ok(r) = parse_compound_pattern_tuple(_ctxt, value) { return Ok(r); }
@ -535,7 +563,11 @@ impl<'a, _L: Copy + Into<&'a crate::gen::Language<_Value>>, _Value: preserves::v
}
}
impl<'a, _L: Copy + Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Unparse<_L, _Value> for CompoundPattern<_Value> {
impl<
'a,
_L: Copy + Into<&'a crate::gen::Language<_Value>>,
_Value: preserves::value::NestedValue + 'a
> _support::Unparse<_L, _Value> for CompoundPattern<_Value> {
fn unparse(&self, _ctxt: _L) -> _Value {
match self {
CompoundPattern::Rec {label: _tmp0, fields: _tmp1} => {
@ -749,7 +781,11 @@ fn parse_definition_pattern<
Ok(Definition::Pattern(std::boxed::Box::new(_tmp0)))
}
impl<'a, _L: Copy + Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Parse<_L, _Value> for Definition<_Value> {
impl<
'a,
_L: Copy + Into<&'a crate::gen::Language<_Value>>,
_Value: preserves::value::NestedValue + 'a
> _support::Parse<_L, _Value> for Definition<_Value> {
fn parse(_ctxt: _L, value: &_Value) -> std::result::Result<Self, _support::ParseError> {
if let Ok(r) = parse_definition_or(_ctxt, value) { return Ok(r); }
if let Ok(r) = parse_definition_and(_ctxt, value) { return Ok(r); }
@ -758,7 +794,11 @@ impl<'a, _L: Copy + Into<&'a crate::gen::Language<_Value>>, _Value: preserves::v
}
}
impl<'a, _L: Copy + Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Unparse<_L, _Value> for Definition<_Value> {
impl<
'a,
_L: Copy + Into<&'a crate::gen::Language<_Value>>,
_Value: preserves::value::NestedValue + 'a
> _support::Unparse<_L, _Value> for Definition<_Value> {
fn unparse(&self, _ctxt: _L) -> _Value {
match self {
Definition::Or {pattern_0: _tmp0, pattern_1: _tmp1, pattern_n: _tmp2} => {
@ -820,7 +860,11 @@ impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value
}
}
impl<'a, _L: Copy + Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Parse<_L, _Value> for Definitions<_Value> {
impl<
'a,
_L: Copy + Into<&'a crate::gen::Language<_Value>>,
_Value: preserves::value::NestedValue + 'a
> _support::Parse<_L, _Value> for Definitions<_Value> {
fn parse(_ctxt: _L, value: &_Value) -> std::result::Result<Self, _support::ParseError> {
let mut _tmp0 = preserves::value::Map::new();
for (_tmp1, _tmp2) in value.value().to_dictionary()? {
@ -832,7 +876,11 @@ impl<'a, _L: Copy + Into<&'a crate::gen::Language<_Value>>, _Value: preserves::v
}
}
impl<'a, _L: Copy + Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Unparse<_L, _Value> for Definitions<_Value> {
impl<
'a,
_L: Copy + Into<&'a crate::gen::Language<_Value>>,
_Value: preserves::value::NestedValue + 'a
> _support::Unparse<_L, _Value> for Definitions<_Value> {
fn unparse(&self, _ctxt: _L) -> _Value {
let Definitions(_tmp0) = self;
preserves::value::Value::Dictionary(_tmp0.iter().map(|(_tmp1, _tmp2)| (preserves::value::Value::symbol(_tmp1).wrap(), _tmp2.unparse(_ctxt))).collect()).wrap()
@ -863,7 +911,11 @@ impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value
}
}
impl<'a, _L: Copy + Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Parse<_L, _Value> for DictionaryEntries<_Value> {
impl<
'a,
_L: Copy + Into<&'a crate::gen::Language<_Value>>,
_Value: preserves::value::NestedValue + 'a
> _support::Parse<_L, _Value> for DictionaryEntries<_Value> {
fn parse(_ctxt: _L, value: &_Value) -> std::result::Result<Self, _support::ParseError> {
let mut _tmp0 = preserves::value::Map::new();
for (_tmp1, _tmp2) in value.value().to_dictionary()? {
@ -875,7 +927,11 @@ impl<'a, _L: Copy + Into<&'a crate::gen::Language<_Value>>, _Value: preserves::v
}
}
impl<'a, _L: Copy + Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Unparse<_L, _Value> for DictionaryEntries<_Value> {
impl<
'a,
_L: Copy + Into<&'a crate::gen::Language<_Value>>,
_Value: preserves::value::NestedValue + 'a
> _support::Unparse<_L, _Value> for DictionaryEntries<_Value> {
fn unparse(&self, _ctxt: _L) -> _Value {
let DictionaryEntries(_tmp0) = self;
preserves::value::Value::Dictionary(_tmp0.iter().map(|(_tmp1, _tmp2)| (_tmp1.clone(), _tmp2.unparse(_ctxt))).collect()).wrap()
@ -935,7 +991,11 @@ fn parse_embedded_type_name_false<
Ok(EmbeddedTypeName::False)
}
impl<'a, _L: Copy + Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Parse<_L, _Value> for EmbeddedTypeName {
impl<
'a,
_L: Copy + Into<&'a crate::gen::Language<_Value>>,
_Value: preserves::value::NestedValue + 'a
> _support::Parse<_L, _Value> for EmbeddedTypeName {
fn parse(_ctxt: _L, value: &_Value) -> std::result::Result<Self, _support::ParseError> {
if let Ok(r) = parse_embedded_type_name_ref(_ctxt, value) { return Ok(r); }
if let Ok(r) = parse_embedded_type_name_false(_ctxt, value) { return Ok(r); }
@ -943,7 +1003,11 @@ impl<'a, _L: Copy + Into<&'a crate::gen::Language<_Value>>, _Value: preserves::v
}
}
impl<'a, _L: Copy + Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Unparse<_L, _Value> for EmbeddedTypeName {
impl<
'a,
_L: Copy + Into<&'a crate::gen::Language<_Value>>,
_Value: preserves::value::NestedValue + 'a
> _support::Unparse<_L, _Value> for EmbeddedTypeName {
fn unparse(&self, _ctxt: _L) -> _Value {
match self {
EmbeddedTypeName::Ref(_tmp0) => _tmp0.as_ref().unparse(_ctxt),
@ -973,7 +1037,11 @@ impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value
}
}
impl<'a, _L: Copy + Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Parse<_L, _Value> for ModulePath {
impl<
'a,
_L: Copy + Into<&'a crate::gen::Language<_Value>>,
_Value: preserves::value::NestedValue + 'a
> _support::Parse<_L, _Value> for ModulePath {
fn parse(_ctxt: _L, value: &_Value) -> std::result::Result<Self, _support::ParseError> {
let _tmp1 = value.value().to_sequence()?;
let mut _tmp0 = std::vec::Vec::new();
@ -985,7 +1053,11 @@ impl<'a, _L: Copy + Into<&'a crate::gen::Language<_Value>>, _Value: preserves::v
}
}
impl<'a, _L: Copy + Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Unparse<_L, _Value> for ModulePath {
impl<
'a,
_L: Copy + Into<&'a crate::gen::Language<_Value>>,
_Value: preserves::value::NestedValue + 'a
> _support::Unparse<_L, _Value> for ModulePath {
fn unparse(&self, _ctxt: _L) -> _Value {
let ModulePath(_tmp0) = self;
{
@ -1022,7 +1094,11 @@ impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value
}
}
impl<'a, _L: Copy + Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Parse<_L, _Value> for Modules<_Value> {
impl<
'a,
_L: Copy + Into<&'a crate::gen::Language<_Value>>,
_Value: preserves::value::NestedValue + 'a
> _support::Parse<_L, _Value> for Modules<_Value> {
fn parse(_ctxt: _L, value: &_Value) -> std::result::Result<Self, _support::ParseError> {
let mut _tmp0 = preserves::value::Map::new();
for (_tmp1, _tmp2) in value.value().to_dictionary()? {
@ -1034,7 +1110,11 @@ impl<'a, _L: Copy + Into<&'a crate::gen::Language<_Value>>, _Value: preserves::v
}
}
impl<'a, _L: Copy + Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Unparse<_L, _Value> for Modules<_Value> {
impl<
'a,
_L: Copy + Into<&'a crate::gen::Language<_Value>>,
_Value: preserves::value::NestedValue + 'a
> _support::Unparse<_L, _Value> for Modules<_Value> {
fn unparse(&self, _ctxt: _L) -> _Value {
let Modules(_tmp0) = self;
preserves::value::Value::Dictionary(_tmp0.iter().map(|(_tmp1, _tmp2)| (_tmp1.unparse(_ctxt), _tmp2.unparse(_ctxt))).collect()).wrap()
@ -1064,7 +1144,11 @@ impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value
}
}
impl<'a, _L: Copy + Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Parse<_L, _Value> for NamedAlternative<_Value> {
impl<
'a,
_L: Copy + Into<&'a crate::gen::Language<_Value>>,
_Value: preserves::value::NestedValue + 'a
> _support::Parse<_L, _Value> for NamedAlternative<_Value> {
fn parse(_ctxt: _L, value: &_Value) -> std::result::Result<Self, _support::ParseError> {
let _tmp0 = value.value().to_sequence()?;
if _tmp0.len() < 2 { return Err(_support::ParseError::conformance_error("schema.NamedAlternative")); }
@ -1074,7 +1158,11 @@ impl<'a, _L: Copy + Into<&'a crate::gen::Language<_Value>>, _Value: preserves::v
}
}
impl<'a, _L: Copy + Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Unparse<_L, _Value> for NamedAlternative<_Value> {
impl<
'a,
_L: Copy + Into<&'a crate::gen::Language<_Value>>,
_Value: preserves::value::NestedValue + 'a
> _support::Unparse<_L, _Value> for NamedAlternative<_Value> {
fn unparse(&self, _ctxt: _L) -> _Value {
let NamedAlternative {variant_label: _tmp0, pattern: _tmp1} = self;
{
@ -1131,7 +1219,11 @@ fn parse_named_pattern_anonymous<
Ok(NamedPattern::Anonymous(std::boxed::Box::new(_tmp0)))
}
impl<'a, _L: Copy + Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Parse<_L, _Value> for NamedPattern<_Value> {
impl<
'a,
_L: Copy + Into<&'a crate::gen::Language<_Value>>,
_Value: preserves::value::NestedValue + 'a
> _support::Parse<_L, _Value> for NamedPattern<_Value> {
fn parse(_ctxt: _L, value: &_Value) -> std::result::Result<Self, _support::ParseError> {
if let Ok(r) = parse_named_pattern_named(_ctxt, value) { return Ok(r); }
if let Ok(r) = parse_named_pattern_anonymous(_ctxt, value) { return Ok(r); }
@ -1139,7 +1231,11 @@ impl<'a, _L: Copy + Into<&'a crate::gen::Language<_Value>>, _Value: preserves::v
}
}
impl<'a, _L: Copy + Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Unparse<_L, _Value> for NamedPattern<_Value> {
impl<
'a,
_L: Copy + Into<&'a crate::gen::Language<_Value>>,
_Value: preserves::value::NestedValue + 'a
> _support::Unparse<_L, _Value> for NamedPattern<_Value> {
fn unparse(&self, _ctxt: _L) -> _Value {
match self {
NamedPattern::Named(_tmp0) => _tmp0.as_ref().unparse(_ctxt),
@ -1193,7 +1289,11 @@ fn parse_named_simple_pattern_anonymous<
Ok(NamedSimplePattern::Anonymous(std::boxed::Box::new(_tmp0)))
}
impl<'a, _L: Copy + Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Parse<_L, _Value> for NamedSimplePattern<_Value> {
impl<
'a,
_L: Copy + Into<&'a crate::gen::Language<_Value>>,
_Value: preserves::value::NestedValue + 'a
> _support::Parse<_L, _Value> for NamedSimplePattern<_Value> {
fn parse(_ctxt: _L, value: &_Value) -> std::result::Result<Self, _support::ParseError> {
if let Ok(r) = parse_named_simple_pattern_named(_ctxt, value) { return Ok(r); }
if let Ok(r) = parse_named_simple_pattern_anonymous(_ctxt, value) { return Ok(r); }
@ -1201,7 +1301,11 @@ impl<'a, _L: Copy + Into<&'a crate::gen::Language<_Value>>, _Value: preserves::v
}
}
impl<'a, _L: Copy + Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Unparse<_L, _Value> for NamedSimplePattern<_Value> {
impl<
'a,
_L: Copy + Into<&'a crate::gen::Language<_Value>>,
_Value: preserves::value::NestedValue + 'a
> _support::Unparse<_L, _Value> for NamedSimplePattern<_Value> {
fn unparse(&self, _ctxt: _L) -> _Value {
match self {
NamedSimplePattern::Named(_tmp0) => _tmp0.as_ref().unparse(_ctxt),
@ -1255,7 +1359,11 @@ fn parse_pattern_compound_pattern<
Ok(Pattern::CompoundPattern(std::boxed::Box::new(_tmp0)))
}
impl<'a, _L: Copy + Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Parse<_L, _Value> for Pattern<_Value> {
impl<
'a,
_L: Copy + Into<&'a crate::gen::Language<_Value>>,
_Value: preserves::value::NestedValue + 'a
> _support::Parse<_L, _Value> for Pattern<_Value> {
fn parse(_ctxt: _L, value: &_Value) -> std::result::Result<Self, _support::ParseError> {
if let Ok(r) = parse_pattern_simple_pattern(_ctxt, value) { return Ok(r); }
if let Ok(r) = parse_pattern_compound_pattern(_ctxt, value) { return Ok(r); }
@ -1263,7 +1371,11 @@ impl<'a, _L: Copy + Into<&'a crate::gen::Language<_Value>>, _Value: preserves::v
}
}
impl<'a, _L: Copy + Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Unparse<_L, _Value> for Pattern<_Value> {
impl<
'a,
_L: Copy + Into<&'a crate::gen::Language<_Value>>,
_Value: preserves::value::NestedValue + 'a
> _support::Unparse<_L, _Value> for Pattern<_Value> {
fn unparse(&self, _ctxt: _L) -> _Value {
match self {
Pattern::SimplePattern(_tmp0) => _tmp0.as_ref().unparse(_ctxt),
@ -1305,7 +1417,11 @@ impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value
}
}
impl<'a, _L: Copy + Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Parse<_L, _Value> for Ref {
impl<
'a,
_L: Copy + Into<&'a crate::gen::Language<_Value>>,
_Value: preserves::value::NestedValue + 'a
> _support::Parse<_L, _Value> for Ref {
fn parse(_ctxt: _L, value: &_Value) -> std::result::Result<Self, _support::ParseError> {
let _tmp0 = value.value().to_record(None)?;
if _tmp0.label() != &_ctxt.into().LIT_16_REF { return Err(_support::ParseError::conformance_error("schema.Ref")); }
@ -1317,7 +1433,11 @@ impl<'a, _L: Copy + Into<&'a crate::gen::Language<_Value>>, _Value: preserves::v
}
}
impl<'a, _L: Copy + Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Unparse<_L, _Value> for Ref {
impl<
'a,
_L: Copy + Into<&'a crate::gen::Language<_Value>>,
_Value: preserves::value::NestedValue + 'a
> _support::Unparse<_L, _Value> for Ref {
fn unparse(&self, _ctxt: _L) -> _Value {
let Ref {module: _tmp0, name: _tmp1} = self;
{
@ -1396,7 +1516,11 @@ impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value
}
}
impl<'a, _L: Copy + Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Parse<_L, _Value> for Schema<_Value> {
impl<
'a,
_L: Copy + Into<&'a crate::gen::Language<_Value>>,
_Value: preserves::value::NestedValue + 'a
> _support::Parse<_L, _Value> for Schema<_Value> {
fn parse(_ctxt: _L, value: &_Value) -> std::result::Result<Self, _support::ParseError> {
let _tmp0 = value.value().to_record(None)?;
if _tmp0.label() != &_ctxt.into().LIT_17_SCHEMA { return Err(_support::ParseError::conformance_error("schema.Schema")); }
@ -1413,7 +1537,11 @@ impl<'a, _L: Copy + Into<&'a crate::gen::Language<_Value>>, _Value: preserves::v
}
}
impl<'a, _L: Copy + Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Unparse<_L, _Value> for Schema<_Value> {
impl<
'a,
_L: Copy + Into<&'a crate::gen::Language<_Value>>,
_Value: preserves::value::NestedValue + 'a
> _support::Unparse<_L, _Value> for Schema<_Value> {
fn unparse(&self, _ctxt: _L) -> _Value {
let Schema {definitions: _tmp0, embedded_type: _tmp1, version: _tmp2} = self;
{
@ -1712,7 +1840,11 @@ fn parse_simple_pattern_ref<
Ok(SimplePattern::Ref(std::boxed::Box::new(_tmp0)))
}
impl<'a, _L: Copy + Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Parse<_L, _Value> for SimplePattern<_Value> {
impl<
'a,
_L: Copy + Into<&'a crate::gen::Language<_Value>>,
_Value: preserves::value::NestedValue + 'a
> _support::Parse<_L, _Value> for SimplePattern<_Value> {
fn parse(_ctxt: _L, value: &_Value) -> std::result::Result<Self, _support::ParseError> {
if let Ok(r) = parse_simple_pattern_any(_ctxt, value) { return Ok(r); }
if let Ok(r) = parse_simple_pattern_atom(_ctxt, value) { return Ok(r); }
@ -1726,7 +1858,11 @@ impl<'a, _L: Copy + Into<&'a crate::gen::Language<_Value>>, _Value: preserves::v
}
}
impl<'a, _L: Copy + Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Unparse<_L, _Value> for SimplePattern<_Value> {
impl<
'a,
_L: Copy + Into<&'a crate::gen::Language<_Value>>,
_Value: preserves::value::NestedValue + 'a
> _support::Unparse<_L, _Value> for SimplePattern<_Value> {
fn unparse(&self, _ctxt: _L) -> _Value {
match self {
SimplePattern::Any => (&_ctxt.into().LIT_21_ANY).clone(),
@ -1785,7 +1921,11 @@ impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value
}
}
impl<'a, _L: Copy + Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Parse<_L, _Value> for Version {
impl<
'a,
_L: Copy + Into<&'a crate::gen::Language<_Value>>,
_Value: preserves::value::NestedValue + 'a
> _support::Parse<_L, _Value> for Version {
fn parse(_ctxt: _L, value: &_Value) -> std::result::Result<Self, _support::ParseError> {
if value != &_ctxt.into().LIT_28_1 { return Err(_support::ParseError::conformance_error("schema.Version")); }
let _tmp0 = ();
@ -1793,7 +1933,11 @@ impl<'a, _L: Copy + Into<&'a crate::gen::Language<_Value>>, _Value: preserves::v
}
}
impl<'a, _L: Copy + Into<&'a crate::gen::Language<_Value>>, _Value: preserves::value::NestedValue + 'a> _support::Unparse<_L, _Value> for Version {
impl<
'a,
_L: Copy + Into<&'a crate::gen::Language<_Value>>,
_Value: preserves::value::NestedValue + 'a
> _support::Unparse<_L, _Value> for Version {
fn unparse(&self, _ctxt: _L) -> _Value {
let Version = self;
(&_ctxt.into().LIT_28_1).clone()