diff --git a/compiler/fluxc_parser/src/lib.rs b/compiler/fluxc_parser/src/lib.rs index 49f999e..3e11137 100644 --- a/compiler/fluxc_parser/src/lib.rs +++ b/compiler/fluxc_parser/src/lib.rs @@ -1,6 +1,4 @@ //! Defines the parser for Flux code. -#![feature(option_result_contains)] - use std::rc::Rc; use fluxc_ast::{Ident, Node, Stmt, AST}; @@ -12,6 +10,7 @@ mod expr; mod span; mod stmt; mod ty; +mod util; /// Internal moduel to prevent leakage of the `Rule` type to external /// crates. diff --git a/compiler/fluxc_parser/src/stmt/func_decl.rs b/compiler/fluxc_parser/src/stmt/func_decl.rs index 73e3704..81d7231 100644 --- a/compiler/fluxc_parser/src/stmt/func_decl.rs +++ b/compiler/fluxc_parser/src/stmt/func_decl.rs @@ -3,7 +3,7 @@ use fluxc_span::Span; use fluxc_types::Type; use pest::iterators::Pair; -use crate::{unexpected_rule, Context, PResult, Parse, Rule}; +use crate::{unexpected_rule, Context, PResult, Parse, Rule, util::Contains}; impl Parse for FuncCall { #[tracing::instrument] diff --git a/compiler/fluxc_parser/src/util.rs b/compiler/fluxc_parser/src/util.rs new file mode 100644 index 0000000..931bbe2 --- /dev/null +++ b/compiler/fluxc_parser/src/util.rs @@ -0,0 +1,13 @@ +pub trait Contains { + /// Test if the target contains `other`. + fn contains(&self, other: &P) -> bool; +} + +impl Contains

for Option

{ + fn contains(&self, other: &P) -> bool { + match self.as_ref() { + Some(s) => s.eq(other), + None => false, + } + } +}