1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
use super::super::prelude::*;
use core::clone::Clone;

verus! {

#[verifier::external_trait_specification]
pub trait ExClone: Sized {
    type ExternalTraitSpecificationFor: core::clone::Clone;

    fn clone(&self) -> Self;
}

/*
#[verifier::external_fn_specification]
pub fn ex_clone_clone_from<T: Clone>(a: &mut T, b: &T)
{
    a.clone_from(b)
}
*/

#[verifier::external_fn_specification]
pub fn ex_bool_clone(b: &bool) -> (res: bool)
    ensures
        res == b,
{
    b.clone()
}

#[verifier::external_fn_specification]
pub fn ex_char_clone(c: &char) -> (res: char)
    ensures
        res == c,
{
    c.clone()
}

#[allow(suspicious_double_ref_op)]
#[verifier::external_fn_specification]
pub fn ex_ref_clone<'b, T: ?Sized, 'a>(b: &'a &'b T) -> (res: &'b T)
    ensures
        res == b,
{
    b.clone()
}

/*
#[verifier::external_fn_specification]
pub fn ex_bool_clone_from(dest: &mut bool, source: &bool)
    ensures *dest == source,
{
    dest.clone_from(source)
}
*/

// Cloning a Tracked copies the underlying ghost T
#[verifier::external_fn_specification]
pub fn ex_tracked_clone<T: Copy>(b: &Tracked<T>) -> (res: Tracked<T>)
    ensures
        res == b,
{
    b.clone()
}

#[verifier::external_fn_specification]
pub fn ex_ghost_clone<T>(b: &Ghost<T>) -> (res: Ghost<T>)
    ensures
        res == b,
{
    b.clone()
}

} // verus!