Currently, Mun only allows functions to be defined independent from a struct. We want to be able to associate functions with a struct type, as such:
pub struct Foo {
x: f32,
y: f32
}
impl Foo {
pub fn new(x: f32, y: f32) -> Self {
Self { x, y }
}
pub fn set_x(&mut self, x: f32) {
self.x = x;
}
}
The above syntax is hypothetical. An important question to consider is whether we need to have a special case for struct(gc) vs struct(value).
Similar to Rust, impl blocks for member functions can be spread across multiple source files.
Definition of Done
Currently, Mun only allows functions to be defined independent from a struct. We want to be able to associate functions with a struct type, as such:
The above syntax is hypothetical. An important question to consider is whether we need to have a special case for
struct(gc)vsstruct(value).Similar to Rust,
implblocks for member functions can be spread across multiple source files.Definition of Done
implblocks feat: parsing & hir of impl blocks #551selfin function signatures feat: infer self & Self HIR types #564