`Entity::clone()` may return values different from `Copy`
ImmemorConsultrixContrarie opened this issue · 0 comments
ImmemorConsultrixContrarie commented
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:
- Using
ent.clone()
could give the user a value different from*ent
. This is kinda awful, becausesane_logic
function would panic:
fn sane_logic<T: Copy>(t: &T) {
assert_eq!(t.clone(), *t);
}
- 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 callsclone()
instead of making a copy, he would spend time accessing thread-local hashmap inside theRefCell
. May slow some things generic overClone
instead ofCopy
, likeiter.cloned()
instead ofiter.map(|x| *x)
.