Skip to content

Tuple elements #6590

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions mk/platform.mk
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,32 @@ CFG_RUN_arm-linux-androideabi=
CFG_RUN_TARG_arm-linux-androideabi=
RUSTC_FLAGS_arm-linux-androideabi :=--android-cross-path=$(CFG_ANDROID_CROSS_PATH)

# arm-unknown-linux-gnueabihf configuration
CC_arm-unknown-linux-gnueabihf=arm-linux-gnueabihf-gcc
CXX_arm-unknown-linux-gnueabihf=arm-linux-gnueabihf-g++
CPP_arm-unknown-linux-gnueabihf=arm-linux-gnueabihf-gcc -E
AR_arm-unknown-linux-gnueabihf=arm-linux-gnueabihf-ar
CFG_LIB_NAME_arm-unknown-linux-gnueabihf=lib$(1).so
CFG_LIB_GLOB_arm-unknown-linux-gnueabihf=lib$(1)-*.so
CFG_LIB_DSYM_GLOB_arm-unknown-linux-gnueabihf=lib$(1)-*.dylib.dSYM
CFG_GCCISH_CFLAGS_arm-unknown-linux-gnueabihf := -Wall -g -fPIC
CFG_GCCISH_CXXFLAGS_arm-unknown-linux-gnueabihf := -fno-rtti
CFG_GCCISH_LINK_FLAGS_arm-unknown-linux-gnueabihf := -shared -fPIC -g
CFG_GCCISH_DEF_FLAG_arm-unknown-linux-gnueabihf := -Wl,--export-dynamic,--dynamic-list=
CFG_GCCISH_PRE_LIB_FLAGS_arm-unknown-linux-gnueabihf := -Wl,-whole-archive
CFG_GCCISH_POST_LIB_FLAGS_arm-unknown-linux-gnueabihf := -Wl,-no-whole-archive
CFG_DEF_SUFFIX_arm-unknown-linux-gnueabihf := .linux.def
CFG_INSTALL_NAME_ar,-unknown-linux-gnueabihf =
CFG_LIBUV_LINK_FLAGS_arm-unknown-linux-gnueabihf =
CFG_EXE_SUFFIX_arm-unknown-linux-gnueabihf :=
CFG_WINDOWSY_arm-unknown-linux-gnueabihf :=
CFG_UNIXY_arm-unknown-linux-gnueabihf := 1
CFG_PATH_MUNGE_arm-unknown-linux-gnueabihf := true
CFG_LDPATH_arm-unknown-linux-gnueabihf :=
CFG_RUN_arm-unknown-linux-gnueabihf=
CFG_RUN_TARG_arm-unknown-linux-gnueabihf=
RUSTC_FLAGS_arm-unknown-linux-gnueabihf := --linker=$(CC_arm-unknown-linux-gnueabihf)

# mips-unknown-linux-gnu configuration
CC_mips-unknown-linux-gnu=mips-linux-gnu-gcc
CXX_mips-unknown-linux-gnu=mips-linux-gnu-g++
Expand Down
4 changes: 4 additions & 0 deletions mk/rt.mk
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@
# Hack for passing flags into LIBUV, see below.
LIBUV_FLAGS_i386 = -m32 -fPIC
LIBUV_FLAGS_x86_64 = -m64 -fPIC
ifeq ($(OSTYPE_$(1)), linux-androideabi)
LIBUV_FLAGS_arm = -fPIC -DANDROID -std=gnu99
else
LIBUV_FLAGS_arm = -fPIC -std=gnu99
endif
LIBUV_FLAGS_mips = -fPIC -mips32r2 -msoft-float -mabi=32

# when we're doing a snapshot build, we intentionally degrade as many
Expand Down
10 changes: 4 additions & 6 deletions src/libcore/bool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,10 @@ pub fn is_false(v: bool) -> bool { !v }
/// Parse logic value from `s`
impl FromStr for bool {
fn from_str(s: &str) -> Option<bool> {
if s == "true" {
Some(true)
} else if s == "false" {
Some(false)
} else {
None
match s {
"true" => Some(true),
"false" => Some(false),
_ => None,
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/libcore/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,11 @@ totalord_impl!(uint)

totalord_impl!(char)

/// Compares (a1, b1) against (a2, b2), where the a values are more significant.
pub fn cmp2<A:TotalOrd,B:TotalOrd>(
a1: &A, b1: &B,
a2: &A, b2: &B) -> Ordering
{
//! Compares (a1, b1) against (a2, b2), where the a values are more significant.

match a1.cmp(a2) {
Less => Less,
Greater => Greater,
Expand Down
88 changes: 38 additions & 50 deletions src/libcore/either.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,22 @@ pub enum Either<T, U> {
Right(U)
}

/// Applies a function based on the given either value
///
/// If `value` is left(T) then `f_left` is applied to its contents, if
/// `value` is right(U) then `f_right` is applied to its contents, and the
/// result is returned.
#[inline(always)]
pub fn either<T, U, V>(f_left: &fn(&T) -> V,
f_right: &fn(&U) -> V, value: &Either<T, U>) -> V {
/*!
* Applies a function based on the given either value
*
* If `value` is left(T) then `f_left` is applied to its contents, if
* `value` is right(U) then `f_right` is applied to its contents, and the
* result is returned.
*/

match *value {
Left(ref l) => f_left(l),
Right(ref r) => f_right(r)
Left(ref l) => f_left(l),
Right(ref r) => f_right(r)
}
}

/// Extracts from a vector of either all the left values
pub fn lefts<T:Copy,U>(eithers: &[Either<T, U>]) -> ~[T] {
//! Extracts from a vector of either all the left values

do vec::build_sized(eithers.len()) |push| {
for eithers.each |elt| {
match *elt {
Expand All @@ -56,9 +52,8 @@ pub fn lefts<T:Copy,U>(eithers: &[Either<T, U>]) -> ~[T] {
}
}

/// Extracts from a vector of either all the right values
pub fn rights<T, U: Copy>(eithers: &[Either<T, U>]) -> ~[U] {
//! Extracts from a vector of either all the right values

do vec::build_sized(eithers.len()) |push| {
for eithers.each |elt| {
match *elt {
Expand All @@ -69,80 +64,73 @@ pub fn rights<T, U: Copy>(eithers: &[Either<T, U>]) -> ~[U] {
}
}

pub fn partition<T, U>(eithers: ~[Either<T, U>])
-> (~[T], ~[U]) {
/*!
* Extracts from a vector of either all the left values and right values
*
* Returns a structure containing a vector of left values and a vector of
* right values.
*/

/// Extracts from a vector of either all the left values and right values
///
/// Returns a structure containing a vector of left values and a vector of
/// right values.
pub fn partition<T, U>(eithers: ~[Either<T, U>]) -> (~[T], ~[U]) {
let mut lefts: ~[T] = ~[];
let mut rights: ~[U] = ~[];
do vec::consume(eithers) |_i, elt| {
match elt {
Left(l) => lefts.push(l),
Right(r) => rights.push(r)
Left(l) => lefts.push(l),
Right(r) => rights.push(r)
}
}
return (lefts, rights);
}

/// Flips between left and right of a given either
#[inline(always)]
pub fn flip<T, U>(eith: Either<T, U>) -> Either<U, T> {
//! Flips between left and right of a given either

match eith {
Right(r) => Left(r),
Left(l) => Right(l)
Right(r) => Left(r),
Left(l) => Right(l)
}
}

/// Converts either::t to a result::t
///
/// Converts an `either` type to a `result` type, making the "right" choice
/// an ok result, and the "left" choice a fail
#[inline(always)]
pub fn to_result<T, U>(eith: Either<T, U>)
-> Result<U, T> {
/*!
* Converts either::t to a result::t
*
* Converts an `either` type to a `result` type, making the "right" choice
* an ok result, and the "left" choice a fail
*/

pub fn to_result<T, U>(eith: Either<T, U>) -> Result<U, T> {
match eith {
Right(r) => result::Ok(r),
Left(l) => result::Err(l)
Right(r) => result::Ok(r),
Left(l) => result::Err(l)
}
}

/// Checks whether the given value is a left
#[inline(always)]
pub fn is_left<T, U>(eith: &Either<T, U>) -> bool {
//! Checks whether the given value is a left

match *eith { Left(_) => true, _ => false }
match *eith {
Left(_) => true,
_ => false
}
}

/// Checks whether the given value is a right
#[inline(always)]
pub fn is_right<T, U>(eith: &Either<T, U>) -> bool {
//! Checks whether the given value is a right

match *eith { Right(_) => true, _ => false }
match *eith {
Right(_) => true,
_ => false
}
}

/// Retrieves the value in the left branch. Fails if the either is Right.
#[inline(always)]
pub fn unwrap_left<T,U>(eith: Either<T,U>) -> T {
//! Retrieves the value in the left branch. Fails if the either is Right.

match eith {
Left(x) => x,
Right(_) => fail!("either::unwrap_left Right")
}
}

/// Retrieves the value in the right branch. Fails if the either is Left.
#[inline(always)]
pub fn unwrap_right<T,U>(eith: Either<T,U>) -> U {
//! Retrieves the value in the right branch. Fails if the either is Left.

match eith {
Right(x) => x,
Left(_) => fail!("either::unwrap_right Left")
Expand Down
Loading