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

Add Copy trait for builtin #1447

Closed
illusory0x0 opened this issue Jan 9, 2025 · 2 comments
Closed

Add Copy trait for builtin #1447

illusory0x0 opened this issue Jan 9, 2025 · 2 comments

Comments

@illusory0x0
Copy link
Contributor

illusory0x0 commented Jan 9, 2025

if a container type always mutable and element type is Immutable, we just invoke copy method to impl Clone trait.

if we hava Functor trait and Copy trait, we can simply get a default implementation

impl[T : Clone] Clone for Array[T] with mutability() { Mutable }

impl[T : Clone] Clone for Array[T] with clone(self) {
  match T::mutability() {
    Mutable => self.map(T::clone)
    Immutable => self.copy_array()
  }
}
@Lampese
Copy link
Collaborator

Lampese commented Jan 9, 2025

I also think that if we had Clone traits, then Copy traits would be necessary, similar to Rust, but is Functor traits really necessary?

cc @peter-jerry-ye

@peter-jerry-ye
Copy link
Collaborator

I think the proposal is simply unnecessary.

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

3 participants