Skip to content

Commit 6fad598

Browse files
authored
Merge pull request #1827 from verus-lang/option-view-export
Move View and DeepView impls of Option to vstd::view
2 parents c229940 + 873f032 commit 6fad598

2 files changed

Lines changed: 19 additions & 19 deletions

File tree

source/vstd/std_specs/option.rs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,6 @@ use core::option::Option::Some;
77

88
verus! {
99

10-
impl<T> View for Option<T> {
11-
type V = Option<T>;
12-
13-
open spec fn view(&self) -> Option<T> {
14-
*self
15-
}
16-
}
17-
18-
impl<T: DeepView> DeepView for Option<T> {
19-
type V = Option<T::V>;
20-
21-
open spec fn deep_view(&self) -> Option<T::V> {
22-
match self {
23-
Some(t) => Some(t.deep_view()),
24-
None => None,
25-
}
26-
}
27-
}
28-
2910
////// Add is_variant-style spec functions
3011
pub trait OptionAdditionalFns<T>: Sized {
3112
#[deprecated(note = "is_Variant is deprecated - use `->` or `matches` instead: https://verus-lang.github.io/verus/guide/datatypes_enum.html")]

source/vstd/view.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,25 @@ impl<T: DeepView> DeepView for alloc::vec::Vec<T> {
134134
}
135135
}
136136

137+
impl<T> View for Option<T> {
138+
type V = Option<T>;
139+
140+
open spec fn view(&self) -> Option<T> {
141+
*self
142+
}
143+
}
144+
145+
impl<T: DeepView> DeepView for Option<T> {
146+
type V = Option<T::V>;
147+
148+
open spec fn deep_view(&self) -> Option<T::V> {
149+
match self {
150+
Some(t) => Some(t.deep_view()),
151+
None => None,
152+
}
153+
}
154+
}
155+
137156
macro_rules! declare_identity_view {
138157
($t:ty) => {
139158
#[cfg_attr(verus_keep_ghost, verifier::verify)]

0 commit comments

Comments
 (0)