1use super::super::mut_ref::MutRef;
2use super::super::prelude::*;
3use core::pin::Pin;
4
5verus! {
6
7#[verifier::external_type_specification]
8#[verifier::external_body]
9#[verifier::accept_recursive_types(P)]
10pub struct ExPin<P>(Pin<P>);
11
12pub trait PinAdditionalSpecFns<'a, T: ?Sized> {
13 spec fn mut_ref(&self) -> MutRef<'a, T>;
14}
15
16impl<'a, T: ?Sized> PinAdditionalSpecFns<'a, T> for Pin<&'a mut T> {
17 uninterp spec fn mut_ref(&self) -> MutRef<'a, T>;
18}
19
20pub assume_specification<'a, T: Unpin + ?Sized>[ Pin::<&'a mut T>::get_mut ](
21 pin: Pin<&'a mut T>,
22) -> (r: &'a mut T)
23 ensures
24 MutRef::unpack(r) == pin.mut_ref(),
25 &*r == pin.mut_ref().current,
26 &*final(r) == pin.mut_ref().future.value(),
27;
28
29pub trait PinAdditionalFns<P> {
34 spec fn pointer(&self) -> P;
36}
37
38impl<P> PinAdditionalFns<P> for Pin<P> {
39 uninterp spec fn pointer(&self) -> P;
40}
41
42impl<P> View for Pin<P> {
43 type V = P;
44
45 open spec fn view(&self) -> Self::V {
46 self.pointer()
47 }
48}
49
50pub assume_specification<P: core::ops::Deref>[ Pin::<P>::new ](pointer: P) -> (res: Pin<P>) where
51 P::Target: Unpin,
52
53 ensures
54 res.pointer() == pointer,
55;
56
57pub assume_specification<P: core::ops::Deref>[ Pin::<P>::into_inner ](pin: Pin<P>) -> (res:
58 P) where P::Target: Unpin
59 ensures
60 res == pin.pointer(),
61;
62
63pub assume_specification<'a, T: ?Sized>[ Pin::<&'a T>::get_ref ](pin: Pin<&'a T>) -> (res: &'a T)
64 ensures
65 res == pin.pointer(),
66;
67
68pub broadcast axiom fn axiom_pin_mut_ref_pointer<'a, T: ?Sized>(pin: Pin<&'a mut T>)
70 ensures
71 #[trigger] pin.mut_ref() == MutRef::unpack(pin.pointer()),
72;
73
74pub broadcast axiom fn axiom_pin_has_resolved<'a, T: ?Sized>(pin: Pin<&'a mut T>)
75 ensures
76 has_resolved::<Pin<&'a mut T>>(pin) ==> (#[trigger] pin.mut_ref()).future.value()
77 == pin.mut_ref().current,
78;
79
80pub broadcast group group_pin_axioms {
81 axiom_pin_has_resolved,
82 axiom_pin_mut_ref_pointer,
83}
84
85}