Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

impl blocks for struct functions #503

Open
1 of 4 tasks
Wodann opened this issue Jan 2, 2023 · 0 comments
Open
1 of 4 tasks

impl blocks for struct functions #503

Wodann opened this issue Jan 2, 2023 · 0 comments
Assignees
Labels
tracking Tracking issue for an epic
Milestone

Comments

@Wodann
Copy link
Collaborator

Wodann commented Jan 2, 2023

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

@Wodann Wodann added the tracking Tracking issue for an epic label Jan 2, 2023
@Wodann Wodann added this to the Mun v0.6.0 milestone Jan 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tracking Tracking issue for an epic
Projects
None yet
Development

No branches or pull requests

2 participants