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

will allow default implementations? #19

Open
djdisodo opened this issue Jun 16, 2022 · 1 comment
Open

will allow default implementations? #19

djdisodo opened this issue Jun 16, 2022 · 1 comment

Comments

@djdisodo
Copy link

default implementation on functions

trait Foo {
    f: T, mut g: U, h: U = g;
}

i can't explain well enough

in this case using : to set both type of field and implementing will be a bit confusing

@SpekalsG3
Copy link

SpekalsG3 commented Mar 21, 2023

In my opinion, It looks like it's better to forbid them. Fields will be used only on instances in methods that use self (borrow or move). If not using self than we already have static variables. And to access self methods we have to either init struct explicitly and so we can require user to provide values, or we can set them in builder function (e.g. new) and default values can be set there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants