Skip to content

Commit

Permalink
export MergeError
Browse files Browse the repository at this point in the history
  • Loading branch information
ibraheemdev committed Nov 7, 2024
1 parent 1bbb0f2 commit 9ae7036
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,25 @@ impl InsertError {
}

/// A failed merge attempt.
#[derive(Debug, Clone)]
///
/// See [`Router::merge`](crate::Router::merge) for details.
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct MergeError(pub(crate) Vec<InsertError>);

Check warning on line 105 in src/error.rs

View workflow job for this annotation

GitHub Actions / Clippy Lints

item name ends with its containing module's name

Check warning on line 105 in src/error.rs

View workflow job for this annotation

GitHub Actions / Clippy Lints

item name ends with its containing module's name

impl MergeError {
/// Returns a list of [`InsertError`] for every insertion that failed
/// during the merge.
pub fn into_errors(self) -> Vec<InsertError> {

Check warning on line 110 in src/error.rs

View workflow job for this annotation

GitHub Actions / Clippy Lints

this method could have a `#[must_use]` attribute

Check warning on line 110 in src/error.rs

View workflow job for this annotation

GitHub Actions / Clippy Lints

this method could have a `#[must_use]` attribute
self.0
}
}

impl fmt::Display for MergeError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
for error in self.0.iter() {

Check warning on line 117 in src/error.rs

View workflow job for this annotation

GitHub Actions / Clippy Lints

it is more concise to loop over references to containers instead of using explicit iteration methods

Check warning on line 117 in src/error.rs

View workflow job for this annotation

GitHub Actions / Clippy Lints

it is more concise to loop over references to containers instead of using explicit iteration methods
writeln!(f, "{}", error)?;

Check warning on line 118 in src/error.rs

View workflow job for this annotation

GitHub Actions / Clippy Lints

variables can be used directly in the `format!` string

Check warning on line 118 in src/error.rs

View workflow job for this annotation

GitHub Actions / Clippy Lints

variables can be used directly in the `format!` string
}

Ok(())
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ mod params;
mod router;
mod tree;

pub use error::{InsertError, MatchError};
pub use error::{InsertError, MatchError, MergeError};
pub use params::{Params, ParamsIter};
pub use router::{Match, Router};

Expand Down

0 comments on commit 9ae7036

Please sign in to comment.