Skip to content

Commit

Permalink
vstd: add spec for Option::Clone
Browse files Browse the repository at this point in the history
  • Loading branch information
tjhance committed Nov 14, 2024
1 parent 4edba7d commit 71aac59
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions source/vstd/std_specs/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,13 @@ pub fn ex_map<T, U, F: FnOnce(T) -> U>(a: Option<T>, f: F) -> (ret: Option<U>)
a.map(f)
}

#[verifier::external_fn_specification]
pub fn ex_vec_clone<T: Clone>(opt: &Option<T>) -> (res: Option<T>)
ensures
opt.is_none() ==> res.is_none(),
opt.is_some() ==> res.is_some() && call_ensures(T::clone, (&opt.unwrap(),), res.unwrap()),
{
opt.clone()
}

} // verus!

0 comments on commit 71aac59

Please sign in to comment.