小编sta*_*amm的帖子

如何防止值被移动?

我在尝试解决机器人模拟器Exercism练习时玩得很开心,但是我遇到了一个价值转移问题,但我似乎无法解决这个问题:

impl Robot {
    pub fn new(x: isize, y: isize, d: Direction) -> Self {
        Robot { position: Coordinate { x: x, y: y }, direction: d }
    }

    pub fn turn_right(mut self) -> Self {
        match self.direction {
           // ...
        };
        self
    }

    pub fn turn_left(mut self) -> Self {
        match self.direction {
           // ...
        };
        self
    }

    pub fn advance(mut self) -> Self {
        match self.direction {
           // ...
        };
        self
    }

    pub fn instructions(self, instructions: …
Run Code Online (Sandbox Code Playgroud)

move lifetime rust

2
推荐指数
1
解决办法
1307
查看次数

标签 统计

lifetime ×1

move ×1

rust ×1