Skip to content

Commit

Permalink
Add Either::unwrap() helper
Browse files Browse the repository at this point in the history
  • Loading branch information
Gegy committed Mar 19, 2024
1 parent 5e778bb commit ee5fda9
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main/java/com/mojang/datafixers/util/Either.java
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@ public <L2> Either<L2, R> flatMap(final Function<L, Either<L2, R>> function) {
return map(function, Either::right);
}

public static <U> U unwrap(final Either<? extends U, ? extends U> either) {
return either.map(Function.identity(), Function.identity());
}

public static final class Instance<R2> implements Applicative<Mu<R2>, Instance.Mu<R2>>, Traversable<Mu<R2>, Instance.Mu<R2>>, CocartesianLike<Mu<R2>, R2, Instance.Mu<R2>> {
public static final class Mu<R2> implements Applicative.Mu, Traversable.Mu, CocartesianLike.Mu {}

Expand Down

0 comments on commit ee5fda9

Please sign in to comment.