feat(interface-types) Add the Vec1 type to represent a non-empty vector.

`Vec1` is used by `RecordType` to ensure that a record have at least 1
field. Then an `InterfaceValue::Record` is ensured to get at least one
value with the type-checking pass.
This commit is contained in:
Ivan Enderlin
2020-04-03 16:13:44 +02:00
parent 6cef1c244a
commit 3159da5bfe
12 changed files with 136 additions and 39 deletions

View File

@ -1,5 +1,6 @@
use wasmer_interface_types::{
ast::*, decoders::binary::parse, encoders::binary::ToBytes, interpreter::Instruction,
vec1::Vec1,
};
/// Tests an AST to binary, then binary to AST roundtrip.
@ -16,7 +17,7 @@ fn test_binary_encoding_decoding_roundtrip() {
outputs: vec![InterfaceType::S32],
},
Type::Record(RecordType {
fields: vec![InterfaceType::String, InterfaceType::I32],
fields: Vec1::new(vec![InterfaceType::String, InterfaceType::I32]).unwrap(),
}),
],
imports: vec![Import {