amethyst/legion

`Entity::clone()` may return values different from `Copy`

ImmemorConsultrixContrarie opened this issue · 0 comments

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).