Skip to content

Commit

Permalink
simple polymorphic extern_spec for Option<T>
Browse files Browse the repository at this point in the history
  • Loading branch information
enjhnsn2 committed Sep 10, 2024
1 parent e0db387 commit 74ed20c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions flux_support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,22 @@ impl<T> [T] {
#[extern_spec(core::ptr)]
#[refined_by(n: int)]
struct NonNull<T>;


#[extern_spec]
#[refined_by(b: bool)]
enum Option<T> {
#[flux_rs::variant(Option<T>[false])]
None,
#[flux_rs::variant({T} -> Option<T>[true])]
Some(T),
}

#[extern_spec]
impl<T> Option<T> {
#[sig(fn(&Option<T>[@b]) -> bool[b])]
const fn is_some(&self) -> bool;

#[sig(fn(&Option<T>[@b]) -> bool[!b])]
const fn is_none(&self) -> bool;
}

0 comments on commit 74ed20c

Please sign in to comment.