Skip to content

Commit

Permalink
Implement accessor functions instead of pub
Browse files Browse the repository at this point in the history
  • Loading branch information
GodTamIt authored and Licenser committed Apr 15, 2024
1 parent 0fd6d67 commit ece4c08
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ pub enum ErrorType {
Io(std::io::Error),
}

#[derive(Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq)]
pub enum InternalError {
TapeError,
}
Expand Down Expand Up @@ -155,11 +155,11 @@ impl PartialEq for ErrorType {
#[derive(Debug, PartialEq)]
pub struct Error {
/// Byte index it was encountered at
pub index: usize,
index: usize,
/// Current character
pub character: Option<char>,
character: Option<char>,
/// Type of error
pub error: ErrorType,
error: ErrorType,
}

impl Error {
Expand All @@ -183,6 +183,21 @@ impl Error {
error: t,
}
}

/// Returns the byte index the error occurred at.
pub fn index(&self) -> usize {
self.index
}

/// Returns the current character the error occurred at.
pub fn character(&self) -> Option<char> {
self.character
}

/// Returns the type of error that occurred.
pub fn error(&self) -> &ErrorType {
&self.error
}
}
impl std::error::Error for Error {}

Expand Down

0 comments on commit ece4c08

Please sign in to comment.