conlang: Add array and slice type syntax
This commit is contained in:
@@ -307,6 +307,8 @@ mod display {
|
||||
TyKind::Never => "!".fmt(f),
|
||||
TyKind::Empty => "()".fmt(f),
|
||||
TyKind::Path(v) => v.fmt(f),
|
||||
TyKind::Array(v) => v.fmt(f),
|
||||
TyKind::Slice(v) => v.fmt(f),
|
||||
TyKind::Tuple(v) => v.fmt(f),
|
||||
TyKind::Ref(v) => v.fmt(f),
|
||||
TyKind::Fn(v) => v.fmt(f),
|
||||
@@ -314,6 +316,20 @@ mod display {
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for TyArray {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
let Self { ty, count } = self;
|
||||
write!(f, "[{ty}; {count}]")
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for TySlice {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
let Self { ty } = self;
|
||||
write!(f, "[{ty}]")
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for TyTuple {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
separate(&self.types, ", ")(f.delimit(INLINE_PARENS))
|
||||
|
||||
Reference in New Issue
Block a user