Remove redundant match on tuple blueprint generation.

This commit is contained in:
KtorZ 2023-03-08 16:40:03 +01:00
parent 2c987e289d
commit a66c9bd2c3
No known key found for this signature in database
GPG Key ID: 33173CB6F77F4277
2 changed files with 16 additions and 29 deletions

View File

@ -250,21 +250,7 @@ impl Annotated<Schema> {
Err(Error::new(ErrorContext::UnboundTypeVariable, type_info)) Err(Error::new(ErrorContext::UnboundTypeVariable, type_info))
} }
}, },
Type::Tuple { elems } => match &elems[..] { Type::Tuple { elems } => {
[left, right] => {
let left = Annotated::from_type(modules, left, type_parameters)?
.into_data(left)
.map_err(|e| e.backtrack(type_info))?;
let right = Annotated::from_type(modules, right, type_parameters)?
.into_data(right)
.map_err(|e| e.backtrack(type_info))?;
Ok(Schema::Data(Data::List(Items::Many(vec![
left.annotated,
right.annotated,
])))
.into())
}
_ => {
let elems = elems let elems = elems
.iter() .iter()
.map(|e| { .map(|e| {
@ -273,13 +259,13 @@ impl Annotated<Schema> {
}) })
.collect::<Result<Vec<_>, _>>() .collect::<Result<Vec<_>, _>>()
.map_err(|e| e.backtrack(type_info))?; .map_err(|e| e.backtrack(type_info))?;
Ok(Annotated { Ok(Annotated {
title: Some("Tuple".to_owned()), title: Some("Tuple".to_owned()),
description: None, description: None,
annotated: Schema::Data(Data::List(Items::Many(elems))), annotated: Schema::Data(Data::List(Items::Many(elems))),
}) })
} }
},
Type::Fn { .. } => Err(Error::new(ErrorContext::UnexpectedFunction, type_info)), Type::Fn { .. } => Err(Error::new(ErrorContext::UnexpectedFunction, type_info)),
} }
} }

View File

@ -470,6 +470,7 @@ mod test {
"title": "test_module.spend", "title": "test_module.spend",
"hash": "3c6766e7a36df2aa13c0e9e6e071317ed39d05f405771c4f1a81c6cc", "hash": "3c6766e7a36df2aa13c0e9e6e071317ed39d05f405771c4f1a81c6cc",
"datum": { "datum": {
"title": "Tuple",
"schema": { "schema": {
"dataType": "list", "dataType": "list",
"items": [ "items": [