Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion engine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ pub use self::{
RegexFormat,
},
scheme::{
Field, FieldIndex, FieldRedefinitionError, Function, FunctionRedefinitionError, Identifier,
Field, FieldIndex, FieldRedefinitionError, Function, FunctionRedefinitionError,
IdentifierRedefinitionError, IndexAccessError, List, Scheme, SchemeBuilder,
SchemeMismatchError, UnknownFieldError,
},
Expand Down
22 changes: 2 additions & 20 deletions engine/src/scheme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,31 +226,13 @@ impl<'s> Function<'s> {
/// An enum to represent an entry inside a [`Scheme`](struct@Scheme).
/// It can be either a [`Field`](struct@Field) or a [`Function`](struct@Function).
#[derive(Debug)]
pub enum Identifier<'s> {
pub(crate) enum Identifier<'s> {
/// Identifier is a [`Field`](struct@Field)
Field(Field<'s>),
/// Identifier is a [`Function`](struct@Function)
Function(Function<'s>),
}

impl<'s> Identifier<'s> {
/// Converts the identifier into a [`Field`](struct@Field) if possible.
pub fn into_field(self) -> Option<Field<'s>> {
match self {
Self::Field(f) => Some(f),
_ => None,
}
}

/// Converts the identifier into a [`Function`](struct@Function) if possible.
pub fn into_function(self) -> Option<Function<'s>> {
match self {
Self::Function(f) => Some(f),
_ => None,
}
}
}

impl<'i, 's> LexWith<'i, &'s Scheme> for Identifier<'s> {
fn lex_with(mut input: &'i str, scheme: &'s Scheme) -> LexResult<'i, Self> {
let initial_input = input;
Expand Down Expand Up @@ -522,7 +504,7 @@ impl<'de> Deserialize<'de> for Scheme {

impl<'s> Scheme {
/// Returns the [`identifier`](enum@Identifier) with the specified `name`.
pub fn get(&'s self, name: &str) -> Option<Identifier<'s>> {
pub(crate) fn get(&'s self, name: &str) -> Option<Identifier<'s>> {
self.inner.items.get(name).map(move |item| match *item {
SchemeItem::Field(index) => Identifier::Field(Field {
scheme: self,
Expand Down
Loading