Skip to content

Commit

Permalink
core: Flesh out the either traits
Browse files Browse the repository at this point in the history
  • Loading branch information
erickt committed Feb 4, 2013
1 parent f4ed7d9 commit 159568e
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/libcore/either.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,23 @@ pub pure fn unwrap_right<T,U>(eith: Either<T,U>) -> U {
}

impl<T, U> Either<T, U> {
#[inline(always)]
fn either<V>(&self, f_left: fn(&T) -> V, f_right: fn(&U) -> V) -> V {
either(f_left, f_right, self)
}

#[inline(always)]
fn flip(self) -> Either<U, T> { flip(self) }

#[inline(always)]
fn to_result(self) -> Result<U, T> { to_result(self) }

#[inline(always)]
fn is_left(&self) -> bool { is_left(self) }

#[inline(always)]
fn is_right(&self) -> bool { is_right(self) }

#[inline(always)]
fn unwrap_left(self) -> T { unwrap_left(self) }

Expand Down

9 comments on commit 159568e

@bors
Copy link
Contributor

@bors bors commented on 159568e Feb 4, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from brson
at erickt@159568e

@bors
Copy link
Contributor

@bors bors commented on 159568e Feb 4, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging erickt/rust/either = 159568e into auto

@bors
Copy link
Contributor

@bors bors commented on 159568e Feb 4, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

erickt/rust/either = 159568e merged ok, testing candidate = 92a3da4d

@bors
Copy link
Contributor

@bors bors commented on 159568e Feb 4, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No active merge of candidate 159568e found, likely manual push to incoming

@bors
Copy link
Contributor

@bors bors commented on 159568e Feb 4, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from brson
at erickt@159568e

@bors
Copy link
Contributor

@bors bors commented on 159568e Feb 4, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging erickt/rust/either = 159568e into auto

@bors
Copy link
Contributor

@bors bors commented on 159568e Feb 4, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

erickt/rust/either = 159568e merged ok, testing candidate = eb28ce0

@bors
Copy link
Contributor

@bors bors commented on 159568e Feb 4, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on 159568e Feb 4, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding incoming to auto = eb28ce0

Please sign in to comment.