Skip to content

Commit

Permalink
Merge pull request #118 from cuviper/clippy
Browse files Browse the repository at this point in the history
Clippy fixes
  • Loading branch information
cuviper authored Feb 23, 2025
2 parents ce345c6 + 81671a6 commit 4db2c30
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ impl<L, R> Either<L, R> {
/// use either::*;
/// let left: Either<_, Vec<u8>> = Left(&["hello"]);
/// assert_eq!(left.factor_into_iter().next(), Some(Left(&"hello")));
///
/// let right: Either<&[&str], _> = Right(vec![0, 1]);
/// assert_eq!(right.factor_into_iter().collect::<Vec<_>>(), vec![Right(0), Right(1)]);
///
Expand All @@ -613,7 +613,7 @@ impl<L, R> Either<L, R> {
/// use either::*;
/// let left: Either<_, Vec<u8>> = Left(["hello"]);
/// assert_eq!(left.factor_iter().next(), Some(Left(&"hello")));
///
/// let right: Either<[&str; 2], _> = Right(vec![0, 1]);
/// assert_eq!(right.factor_iter().collect::<Vec<_>>(), vec![Right(&0), Right(&1)]);
///
Expand All @@ -638,7 +638,7 @@ impl<L, R> Either<L, R> {
/// let mut left: Either<_, Vec<u8>> = Left(["hello"]);
/// left.factor_iter_mut().for_each(|x| *x.unwrap_left() = "goodbye");
/// assert_eq!(left, Left(["goodbye"]));
///
/// let mut right: Either<[&str; 2], _> = Right(vec![0, 1, 2]);
/// right.factor_iter_mut().for_each(|x| if let Right(r) = x { *r = -*r; });
/// assert_eq!(right, Right(vec![0, -1, -2]));
Expand Down Expand Up @@ -1129,10 +1129,9 @@ impl<L, R> From<Result<R, L>> for Either<L, R> {
}

/// Convert from `Either` to `Result` with `Right => Ok` and `Left => Err`.
#[allow(clippy::from_over_into)] // From requires RFC 2451, Rust 1.41
impl<L, R> Into<Result<R, L>> for Either<L, R> {
fn into(self) -> Result<R, L> {
match self {
impl<L, R> From<Either<L, R>> for Result<R, L> {
fn from(val: Either<L, R>) -> Self {
match val {
Left(l) => Err(l),
Right(r) => Ok(r),
}
Expand Down

0 comments on commit 4db2c30

Please sign in to comment.