为何对enum 解引用会引发move?

出错的代码:

#[derive(Debug)]
pub enum Direction {
    Up = 1,
    Down = -1,
    Left = 2,
    Right = -2,
} 
impl Direction {
    fn is_opposite(&self, another: &Self) -> bool {
        (*self as isize) + (*another as isize) == 0
    }
}

错误信息:
图片描述
但是这样的代码是没问题的:

match *self {
    // ...
}

我不太清楚这两者间的区别,为什么前者会引起move 或者copy?

阅读 2.4k
1 个回答
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进