add empty variable slice at index 0

This commit is contained in:
Folkert 2021-08-12 19:35:33 +02:00
parent a12114f0d8
commit e86cc22024

View file

@ -49,7 +49,7 @@ struct ErrorTypeState {
problems: Vec<crate::types::Problem>, problems: Vec<crate::types::Problem>,
} }
#[derive(Default, Clone)] #[derive(Clone)]
pub struct Subs { pub struct Subs {
utable: UnificationTable<InPlace<Variable>>, utable: UnificationTable<InPlace<Variable>>,
pub variables: Vec<Variable>, pub variables: Vec<Variable>,
@ -59,6 +59,21 @@ pub struct Subs {
pub variable_slices: Vec<VariableSubsSlice>, pub variable_slices: Vec<VariableSubsSlice>,
} }
impl Default for Subs {
fn default() -> Self {
Subs {
utable: Default::default(),
variables: Default::default(),
tag_names: Default::default(),
field_names: Default::default(),
record_fields: Default::default(),
// store an empty slice at the first position
// used for "TagOrFunction"
variable_slices: vec![VariableSubsSlice::default()],
}
}
}
/// A slice into the Vec<T> of subs /// A slice into the Vec<T> of subs
/// ///
/// The starting position is a u32 which should be plenty /// The starting position is a u32 which should be plenty
@ -883,7 +898,7 @@ pub enum Builtin {
EmptyRecord, EmptyRecord,
} }
#[derive(Clone, Copy, Debug)] #[derive(Clone, Copy, Debug, Default)]
pub struct VariableSubsSlice { pub struct VariableSubsSlice {
slice: SubsSlice<Variable>, slice: SubsSlice<Variable>,
} }