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 643659801c
commit 419dcc6415
12 changed files with 136 additions and 39 deletions

View File

@ -1,7 +1,7 @@
//! Represents the WIT language as a tree. This is the central
//! representation of the language.
use crate::interpreter::Instruction;
use crate::{interpreter::Instruction, vec1::Vec1};
use std::str;
/// Represents the types supported by WIT.
@ -57,7 +57,7 @@ pub enum InterfaceType {
#[derive(PartialEq, Debug, Clone)]
pub struct RecordType {
/// Types representing the fields.
pub fields: Vec<InterfaceType>,
pub fields: Vec1<InterfaceType>,
}
/// Represents the kind of type.