Skip to content

Commit

Permalink
Renames as pre-requisites for the crate re-name.
Browse files Browse the repository at this point in the history
* `PestionResult` => `PestToIonResult`
* `PestionError` => `PestToIonError`
  • Loading branch information
almann committed Jun 8, 2021
1 parent 783de7f commit e3bef9e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions pestion/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
//! use ion_rs::value::*;
//! use ion_rs::value::reader::*;
//!
//! fn main() -> PestionResult<()> {
//! fn main() -> PestToIonResult<()> {
//! // parse a Pest grammar and convert it to Ion element
//! let actual = r#"a = @{ "a" | "b" ~ "c" }"#.try_pest_to_element()?;
//!
Expand Down Expand Up @@ -60,7 +60,7 @@ pub trait TryPestToElement {
///
/// This returns `Err` if the the conversion fails. For example, this can happen if the
/// source is not a valid Pest grammar.
fn try_pest_to_element(&self) -> PestionResult<Self::Element>;
fn try_pest_to_element(&self) -> PestToIonResult<Self::Element>;
}

/// Infallible conversion of a Pest grammar (or part of a grammar) into Ion [`Element`].
Expand All @@ -78,7 +78,7 @@ impl TryPestToElement for &str {
type Element = OwnedElement;

/// Parses a `str` slice as a Pest grammar and serializes the AST into [`Element`].
fn try_pest_to_element(&self) -> PestionResult<Self::Element> {
fn try_pest_to_element(&self) -> PestToIonResult<Self::Element> {
let pairs = PestParser::parse(Rule::grammar_rules, *self)?;
let ast = match consume_rules(pairs) {
Ok(ast) => ast,
Expand Down Expand Up @@ -422,7 +422,7 @@ mod tests {
},
}"#
)]
fn good<T, S>(#[case] input: T, #[case] ion_literal: S) -> PestionResult<()>
fn good<T, S>(#[case] input: T, #[case] ion_literal: S) -> PestToIonResult<()>
where
T: TryPestToElement<Element = OwnedElement> + Debug,
S: AsRef<str>,
Expand Down Expand Up @@ -452,9 +452,9 @@ mod tests {
#[case::empty_rule(r#"a = {}"#)]
#[case::self_reference(r#"a = { a }"#)]
#[case::double_rule(r#"a = { "a" }\n a = { "b" }"#)]
fn pest_errors<T: TryPestToElement>(#[case] input: T) -> PestionResult<()> {
fn pest_errors<T: TryPestToElement>(#[case] input: T) -> PestToIonResult<()> {
match input.try_pest_to_element() {
Err(PestionError::Pest(_)) => {}
Err(PestToIonError::Pest(_)) => {}
something => {
unreachable!("Got result we did not expect: {:?}", something);
}
Expand Down
8 changes: 4 additions & 4 deletions pestion/src/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
use thiserror::Error;

/// Main [`Result`] type for Pest to Ion.
pub type PestionResult<T> = Result<T, PestionError>;
pub type PestToIonResult<T> = Result<T, PestToIonError>;

/// Error type for problems in this crate.
#[derive(Error, Debug)]
pub enum PestionError {
pub enum PestToIonError {
/// An error working with [`pest_meta`].
#[error("Pest Error: {0}")]
Pest(#[from] pest::error::Error<pest_meta::parser::Rule>),
Expand All @@ -24,6 +24,6 @@ pub enum PestionError {
}

/// Convenience function to create a general error result.
pub fn invalid<T, S: Into<String>>(message: S) -> PestionResult<T> {
Err(PestionError::Invalid(message.into()))
pub fn invalid<T, S: Into<String>>(message: S) -> PestToIonResult<T> {
Err(PestToIonError::Invalid(message.into()))
}

0 comments on commit e3bef9e

Please sign in to comment.