Skip to content

Commit

Permalink
Box the pest::Error in Error to reduce size of Result values
Browse files Browse the repository at this point in the history
  • Loading branch information
althonos committed Feb 24, 2024
1 parent 3f159c9 commit 63862ff
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub enum Error {
/// assert_matches!(res, Err(horned_functional::Error::Pest(_)));
/// ```
#[error(transparent)]
Pest(#[from] pest::error::Error<Rule>),
Pest(Box<pest::error::Error<Rule>>),

/// An error that happened at the I/O level.
///
Expand Down Expand Up @@ -75,7 +75,7 @@ pub enum Error {
impl Error {
// Create a custom `pest` error spanning the given pair.
pub fn custom<S: Into<String>>(message: S, pair: Pair<Rule>) -> Self {
Self::Pest(pest::error::Error::new_from_span(
Self::from(pest::error::Error::new_from_span(
pest::error::ErrorVariant::CustomError {
message: message.into(),
},
Expand All @@ -84,6 +84,12 @@ impl Error {
}
}

impl From<pest::error::Error<Rule>> for Error {
fn from(e: pest::error::Error<Rule>) -> Self {
Error::Pest(Box::new(e))
}
}

impl From<curie::ExpansionError> for Error {
fn from(e: curie::ExpansionError) -> Self {
Error::Expansion(e)
Expand Down

0 comments on commit 63862ff

Please sign in to comment.