summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
2013-05-03rustpkg: Implement install commandTim Chevalier-1/+25
The install command should work now, though it only installs in-place (anything else has to wait until I implement RUST_PATH). Also including: core: Add remove_directory_recursive, change copy_file Make copy_file preserve permissions, and add a remove_directory_recursive function.
2013-05-03auto merge of #6185 : gifnksm/rust/prelude-from_str, r=graydonbors-9/+4
`core::prelude` re-exports `core::to_str::ToStr`, but doesn't re-export `core::from_str::FromStr`. That is inconsistent.
2013-05-03Remove extra `#[cfg(stage0)]`gifnksm-2/+0
2013-05-02std: xfail test_serializing_pipesBrian Anderson-0/+1
2013-05-02librustc: Update the serializer to work properly with INHTWAMA, removing ↵Patrick Walton-203/+2721
mutable fields in the process
2013-05-02libstd: De-mut arenaPatrick Walton-51/+89
2013-05-02libcore: Export core::from_str::FromStr from core::preludegifnksm-8/+5
2013-05-02More cases of [cfg(test)] instead of [test].Felix S. Klock II-1/+1
2013-05-02mod items need to be marked with `cfg(test)` not `test`.Felix S. Klock II-1/+1
2013-05-02Remove 'Local Variable' commentsBrendan Zabarauskas-74/+0
2013-05-02libstd: impl Clone for BigUint/BigInt and replace `copy` with `.clone()`gifnksm-11/+13
2013-05-01keep old sort for stage0Niko Matsakis-0/+1239
2013-05-01correct incorrect handling of overloaded operators, exposing various other ↵Niko Matsakis-62/+78
bits of rot
2013-05-01auto merge of #6147 : bjz/rust/numeric-traits, r=brsonbors-70/+67
After much discussion on IRC and #4819, we have decided to revert to the old naming of the `/` operator. This does not change its behavior. In making this change, we also have had to rename some of the methods in the `Integer` trait. Here is a list of the methods that have changed: - `Quot::quot` -> `Div::div` - `Rem::rem` - stays the same - `Integer::quot_rem` -> `Integer::div_rem` - `Integer::div` -> `Integer::div_floor` - `Integer::modulo` -> `Integer::mod_floor` - `Integer::div_mod` -> `Integer::div_mod_floor`
2013-05-01Revert rename of Div to QuotBrendan Zabarauskas-70/+67
2013-04-30core/std: Fix race condition in os::mkdir_recursive testsTim Chevalier-21/+29
Added a change_dir_locked function to os, and use it in the mkdir_recursive tests so that the tests don't clobber each other's directory changes.
2013-04-30allover: numerous unused muts etcNiko Matsakis-4/+3
2013-04-30new borrow checker (mass squash)Niko Matsakis-53/+65
2013-04-30desnapshotNiko Matsakis-3/+0
2013-04-30adapt to snapshotNiko Matsakis-376/+0
2013-04-29auto merge of #6108 : gifnksm/rust/bigint-shift-bug, r=brsonbors-21/+39
`std::bigint` contains the following code. ```rust borrow = *elem << (uint::bits - n_bits); ``` The code above contains a bug that the value of the right operand of the shift operator exceeds the size of the left operand, because sizeof(*elem) == 32, and 0 <= n_bits < 32 in 64bit architecture. If `--opt-level` option is not given to rustc, the code above runs as if the right operand is `(uint::bits - n_bits) % 32`, but if --opt-level is given, `borrow` is always zero. I wonder why this bug is not catched in the libstd's testsuite (I try the `rustc --test --opt-level=2 bigint.rs` before fixing the bug, but the unittest passes normally.) This pull request also removes the implicit vector copies in `bigint.rs`.
2013-04-29auto merge of #6107 : catamorphism/rust/mkdir_recursive, r=brsonbors-6/+59
r? @brson This hopefully addresses your concerns about the termination condition, and adds more tests. With a bonus documentation commit.
2013-04-29libstd: Fix merge fallout.Patrick Walton-2/+0
2013-04-29librustc: Fix merge fallout.Patrick Walton-0/+1
2013-04-29test: Fix more tests.Patrick Walton-1/+1
2013-04-29librustc: Forbid type implementations on typedefs.Patrick Walton-12/+14
2013-04-29test: Fix tests.Patrick Walton-20/+28
2013-04-29librustc: Remove `ptr::addr_of`.Patrick Walton-108/+98
2013-04-29auto merge of #6110 : bjz/rust/numeric-traits, r=pcwaltonbors-2/+20
As discussed on issue #4819, I have created four new traits: `Algebraic`, `Trigonometric`, `Exponential` and `Hyperbolic`, and moved the appropriate methods into them from `Real`. ~~~rust pub trait Algebraic { fn pow(&self, n: Self) -> Self; fn sqrt(&self) -> Self; fn rsqrt(&self) -> Self; fn cbrt(&self) -> Self; fn hypot(&self, other: Self) -> Self; } pub trait Trigonometric { fn sin(&self) -> Self; fn cos(&self) -> Self; fn tan(&self) -> Self; fn asin(&self) -> Self; fn acos(&self) -> Self; fn atan(&self) -> Self; fn atan2(&self, other: Self) -> Self; } pub trait Exponential { fn exp(&self) -> Self; fn exp2(&self) -> Self; fn expm1(&self) -> Self; fn log(&self) -> Self; fn log2(&self) -> Self; fn log10(&self) -> Self; } pub trait Hyperbolic: Exponential { fn sinh(&self) -> Self; fn cosh(&self) -> Self; fn tanh(&self) -> Self; } ~~~ There was some discussion over whether we should shorten the names, for example `Trig` and `Exp`. No abbreviations have been agreed on yet, but this could be considered in the future. Additionally, `Integer::divisible_by` has been renamed to `Integer::is_multiple_of`.
2013-04-29Rename 'divisible_by' method to 'is_multiple_of', add tests for 'is_odd' and ↵Brendan Zabarauskas-2/+2
'is_even'
2013-04-29Implement Fractional for RatioBrendan Zabarauskas-0/+18
2013-04-29libstd: modify wrong shift width.gifnksm-1/+2
borrow = *elem << (uint::bits - n_bits); The code above contains a bug that the value of the right operand of the shift operator exceeds the size of the left operand, because sizeof(*elem) == 32, and 0 <= n_bits < 32 in 64bit architecture. If `--opt-level` option is not given to rustc, the code above runs as if the right operand is `(uint::bits - n_bits) % 32`, but if --opt-level is given, `borrow` is always zero. I wonder why this bug is not catched in the libstd's testsuite (I try the `rustc --test --opt-level=2 bigint.rs` before fixing the bug, but the unittest passes normally.)
2013-04-29libstd: remove implicit copying of BigInt/BigUintgifnksm-20/+37
2013-04-28core: Use a better termination condition in os::mkdir_recursiveTim Chevalier-6/+59
Instead of checking whether the parent is "." or "/", check the number of components. Also, more tests.
2013-04-28make way for a new iter moduleDaniel Micay-17/+17
2013-04-28auto merge of #6092 : gifnksm/rust/impl-integer-bigint, r=graydonbors-144/+383
This is a follow-up commit for #6041 (and depending on #6048). Also adding `#[inline(always)]` for almost every methods in `std::bigint`.
2013-04-28libstd: inlining almost every methods in bigint module.gifnksm-1/+86
2013-04-28libstd: impl Integer for BigUint/BigInt.gifnksm-143/+297
Also remove abs() method from the non-trait impl for BigInt/BigUint. That method is provided in the Signed trait.
2013-04-27only use #[no_core] in libcoreDaniel Micay-142/+0
2013-04-27auto merge of #6071 : bjz/rust/numeric-traits, r=graydonbors-19/+27
As part of the numeric trait reform (see issue #4819), I have added the following traits to `core::num` and implemented them for Rust's primitive numeric types: ~~~rust pub trait Bitwise: Not<Self> + BitAnd<Self,Self> + BitOr<Self,Self> + BitXor<Self,Self> + Shl<Self,Self> + Shr<Self,Self> {} pub trait BitCount { fn population_count(&self) -> Self; fn leading_zeros(&self) -> Self; fn trailing_zeros(&self) -> Self; } pub trait Bounded { fn min_value() -> Self; fn max_value() -> Self; } pub trait Primitive: Num + NumCast + Bounded + Neg<Self> + Add<Self,Self> + Sub<Self,Self> + Mul<Self,Self> + Quot<Self,Self> + Rem<Self,Self> { fn bits() -> uint; fn bytes() -> uint; } pub trait Int: Integer + Primitive + Bitwise + BitCount {} pub trait Float: Real + Signed + Primitive { fn NaN() -> Self; fn infinity() -> Self; fn neg_infinity() -> Self; fn neg_zero() -> Self; fn is_NaN(&self) -> bool; fn is_infinite(&self) -> bool; fn is_finite(&self) -> bool; fn mantissa_digits() -> uint; fn digits() -> uint; fn epsilon() -> Self; fn min_exp() -> int; fn max_exp() -> int; fn min_10_exp() -> int; fn max_10_exp() -> int; fn mul_add(&self, a: Self, b: Self) -> Self; fn next_after(&self, other: Self) -> Self; } ~~~ Note: I'm not sure my implementation for `BitCount::trailing_zeros` and `BitCount::leading_zeros` is correct for uints. I also need some assistance creating appropriate unit tests for them. More work needs to be done in implementing specialized primitive floating-point and integer methods, but I'm beginning to reach the limits of my knowledge. Please leave your suggestions/critiques/ideas on #4819 if you have them – I'd very much appreciate hearing them. I have also added an `Orderable` trait: ~~~rust pub trait Orderable: Ord { fn min(&self, other: &Self) -> Self; fn max(&self, other: &Self) -> Self; fn clamp(&self, mn: &Self, mx: &Self) -> Self; } ~~~ This is a temporary trait until we have default methods. We don't want to encumber all implementors of Ord by requiring them to implement these functions, but at the same time we want to be able to take advantage of the speed of the specific numeric functions (like the `fmin` and `fmax` intrinsics).
2013-04-27auto merge of #6064 : thestinger/rust/char, r=catamorphismbors-55/+37
2013-04-26Add is_zero method to ZeroBrendan Zabarauskas-19/+27
2013-04-25implement Ord, TotalEq and TotalOrd for charDaniel Micay-55/+37
Closes #6063
2013-04-25Update impl of Round for RatioBrendan Zabarauskas-20/+22
2013-04-25Use #[cfg(not(stage0))] to exclude items from stage0Brendan Zabarauskas-12/+4
As requested on the mailing list: https://mail.mozilla.org/pipermail/rust-dev/2013-April/003713.html
2013-04-25Fix incorrect replacement of `modulo` with `rem`Brendan Zabarauskas-1/+1
2013-04-24Fixed typo... And a billion other things.Marvin Löbel-2/+2
2013-04-24Removed ascii functions from other modulesMarvin Löbel-3/+7
Replaced str::to_lowercase and str::to_uppercase
2013-04-24auto merge of #6036 : huonw/rust/core-less-at, r=nikomatsakisbors-61/+27
From a cursory `git grep` this removes the last part of `core` that requires on `@` (other than `io` and the task local data section). It renames `RandRes` to ~~StdRng~~ `IsaacRng` and `XorShiftState` to `XorShiftRng` as well as moving their constructors to static methods. To go with this, it adds `rng()` which is designed to be used when the programmer just wants a random number generator, without caring about which exact algorithm is being used. It also removes all the `gen_int`, `gen_uint`, `gen_char` (etc) methods on `RngUtil` (by moving the defintions to the actual `Rand` instances). The replacement is using `RngUtil::gen`, either type-inferred or with an annotation (`rng.gen::<uint>()`). I tried to have the `Rng` and `RngUtil` traits exported by `core::prelude` (since `core::rand` (except for `random()`) is useless without them), but this caused [an explosion of (seemingly unrelated) `error: unresolved import`'s](https://gist.github.com/5451839).
2013-04-24libcore: unify `gen_<type>` methods on `rand::RngUtil` into the generic `gen`.Huon Wilson-50/+15
This moves all the basic random value generation into the Rand instances for each type and then removes the `gen_int`, `gen_char` (etc) methods on RngUtil, leaving only the generic `gen` and the more specialised methods. Also, removes some imports that are redundant due to a `use core::prelude::*` statement.