Require explicit cloning of State

This commit is contained in:
Joshua Warner 2021-12-16 17:13:58 -08:00
parent 49818343dd
commit 2e85c19101
5 changed files with 27 additions and 28 deletions

View file

@ -5,7 +5,7 @@ use roc_region::all::{Position, Region};
use std::fmt;
/// A position in a source file.
#[derive(Clone, Copy, PartialEq, Eq)]
#[derive(Clone)]
pub struct State<'a> {
/// The raw input bytes from the file.
bytes: &'a [u8],
@ -36,7 +36,7 @@ impl<'a> State<'a> {
#[must_use]
pub fn advance(&self, offset: usize) -> State<'a> {
let mut state = *self;
let mut state = self.clone();
state.bytes = &state.bytes[offset..];
state
}