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

Entity::clone() may return values different from Copy #248

Open
ImmemorConsultrixContrarie opened this issue Mar 25, 2021 · 0 comments
Open

Comments

@ImmemorConsultrixContrarie
Copy link
Contributor

This code either doesn't uphold a sane Clone invariant or is totally useless for anything but internal use.

So, there are two possible problems:

  1. Using ent.clone() could give the user a value different from *ent. This is kinda awful, because sane_logic function would panic:
fn sane_logic<T: Copy>(t: &T) {
    assert_eq!(t.clone(), *t);
}
  1. Using ent.clone() could not give the user a value different from *ent. This is not as bad as the first problem, but every time the user calls clone() instead of making a copy, he would spend time accessing thread-local hashmap inside the RefCell. May slow some things generic over Clone instead of Copy, like iter.cloned() instead of iter.map(|x| *x).
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

1 participant