use vstd::prelude::*;
verus! {
pub open spec fn cursor_admitted(position: nat, head: nat) -> bool {
position <= head
}
pub proof fn regression_rejected(position: nat, head: nat)
requires position > head,
ensures !cursor_admitted(position, head),
{
}
pub struct Cursor {
pub position: usize,
}
impl Cursor {
pub fn new(position: usize) -> (cursor: Self)
ensures cursor.position == position,
{
Self { position }
}
pub fn advance_to(&mut self, position: usize)
requires old(self).position <= position,
ensures final(self).position == position,
{
self.position = position;
}
}
}