Commit Graph

63 Commits

Author SHA1 Message Date
Brian Anderson
3df7ed15b7 Remove Durable from the language 2013-05-07 17:50:42 -07:00
Brendan Zabarauskas
0211833008 Move FuzzyEq trait into core::cmp and rename it to 'ApproxEq' 2013-05-06 21:51:07 +10:00
Brian Anderson
8081e8debf Register snapshots 2013-05-04 15:43:51 -07:00
bors
4332f8188b auto merge of #6216 : Sodel-the-Vociferous/rust/dralston-6146, r=graydon
cc #6146
2013-05-03 11:33:38 -07:00
Daniel Ralston
02889f7507 Add core::cmp::Equiv to prelude 2013-05-03 01:22:52 -07:00
gifnksm
cff6aba76e libcore: Export core::from_str::FromStr from core::prelude 2013-05-02 20:42:54 +09:00
Brendan Zabarauskas
ee26c7c433 Revert rename of Div to Quot 2013-05-01 15:40:05 +10:00
bors
dbcc3fe63a auto merge of #6110 : bjz/rust/numeric-traits, r=pcwalton
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-29 13:39:37 -07:00
Brendan Zabarauskas
500078e147 Revert "Merge Exponential and Hyperbolic traits"
After discussions on IRC and #4819, we have decided to revert this change. This is due to the traits expressing different ideas and because hyperbolic functions are not trivially implementable from exponential functions for floating-point types.
2013-04-29 23:50:34 +10:00
Brendan Zabarauskas
d3f494f5c3 Merge Exponential and Hyperbolic traits
The Hyperbolic Functions are trivially implemented in terms of `exp`, so it's  simpler to group them the Exponential trait. In the future these would have default implementations.
2013-04-29 22:15:58 +10:00
Brendan Zabarauskas
c9620dc052 Move appropriate functions out of Real and into separate Algebraic, Trigonometric, Exponential and Hyperbolic traits 2013-04-29 15:33:55 +10:00
Daniel Micay
46f91a0fa9 make way for a new iter module 2013-04-28 22:31:39 -04:00
Brendan Zabarauskas
6cc7107aa6 Add Orderable trait
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-27 01:01:53 +10:00
Brendan Zabarauskas
6efbbf2e14 Combine PrimitiveInt, Int, and Uint traits into one single trait
Having three traits for primitive ints/uints seemed rather excessive. If users wish to specify between them they can simply combine Int with either the Signed and Unsigned traits. For example: fn foo<T: Int + Signed>() { … }
2013-04-26 19:56:11 +10:00
Brendan Zabarauskas
d0737451fc Add BitCount trait 2013-04-26 16:27:51 +10:00
Brendan Zabarauskas
4c07f5e457 Add Int, Uint and Float traits for primitive numbers 2013-04-26 10:22:08 +10:00
Brendan Zabarauskas
b62421000c Add Bitwise, Bounded, Primitive, and PrimitiveInt traits 2013-04-26 10:02:00 +10:00
Brendan Zabarauskas
48c24188f9 Restore Round trait and move appropriate methods out of Real 2013-04-25 11:53:04 +10:00
Brendan Zabarauskas
dcd49ccd0b Add Fractional, Real and RealExt traits 2013-04-25 08:20:01 +10:00
Brendan Zabarauskas
024bf2ec72 Rename Natural to Integer
'Natural' normally means 'positive integer' in mathematics. It is therefore strange to implement it on signed integer types. 'Integer' is probably a better choice.
2013-04-25 08:20:00 +10:00
Brendan Zabarauskas
d4868ee740 Use #[cfg(not(stage0))] to exclude items from stage0
As requested on the mailing list: https://mail.mozilla.org/pipermail/rust-dev/2013-April/003713.html
2013-04-25 08:20:00 +10:00
Brendan Zabarauskas
f39152e07b Implement Natural trait
This adds the following methods to ints and uints:

- div
- modulo
- div_mod
- quot_rem
- gcd
- lcm
- divisible_by
- is_even
- is_odd

I have not implemented Natural for BigInt and BigUInt because they're a little over my head.
2013-04-24 14:18:01 +10:00
Brendan Zabarauskas
aef249056e Implement Signed and Unsigned traits and remove related predicate functions 2013-04-24 12:46:26 +10:00
bors
05f9586d06 auto merge of #5980 : Kimundi/rust/ascii-encoding, r=thestinger
Added Ascii type to use for byte inputs that are known to contain Ascii only.
2013-04-22 16:33:51 -07:00
Marvin Löbel
582a05fc95 Moved ascii out of str
Removed deriving Ord, which allowed to remove the stage markers
2013-04-22 21:42:25 +02:00
Brendan Zabarauskas
01eb5e8ad3 Rename Div operator trait to Quot and Modulo operator trait to Rem 2013-04-22 01:58:53 +10:00
Marvin Löbel
61ffee738d Added Ascii type 2013-04-20 22:51:55 +02:00
Patrick Walton
c995a62d44 librustc: WIP patch for using the return value. 2013-04-19 12:00:08 -07:00
Patrick Walton
9738c2a45c test: Rewrite nbody and spectralnorm shootout benchmarks 2013-04-19 11:56:52 -07:00
Brendan Zabarauskas
ce6ee7bb04 Restore Num trait
This restores the trait that was lost in 216e85fadf. It will eventually be broken up into a more fine-grained trait hierarchy in the future once a design can be agreed upon.
2013-04-14 02:19:35 +10:00
Patrick Walton
ef56aa62fb libcore: Add print and println to the prelude 2013-03-28 19:16:06 -07:00
Daniel Micay
d2b267bcb5 add a TotalEq trait 2013-03-27 17:29:10 -04:00
Brian Anderson
113fbfc795 core: Clarify prelude docs. #4556 2013-03-26 11:47:52 -07:00
Marvin Löbel
ee2f3d9673 Switched over substr and trim functions in str to be non-allocating, temporary renamed them to better track use-sites 2013-03-21 23:06:04 +01:00
Graydon Hoare
bb9e1e2660 core: add Reader, Writer, ReaderUtil, WriterUtil to prelude. Close #4182. 2013-03-20 13:48:57 -07:00
bors
c3fe0b97de auto merge of #5369 : thestinger/rust/iter, r=z0w0
This can eventually be implemented on other sequence containers like `deque` (it's missing `each` too at the moment).
2013-03-14 19:06:47 -07:00
Daniel Micay
c64a5d2d37 add a trait for mutable iterators 2013-03-13 21:29:48 -04:00
Brian Anderson
34113dcf6a core: Add spawn, stream and friends to prelude. #5299 2013-03-13 18:17:12 -07:00
Brian Anderson
cb37d09f50 core: Remove logging constants 2013-03-11 23:19:42 -07:00
Alex Crichton
59de3853be core: Remove the dvec module 2013-03-08 09:54:41 -05:00
bors
2304fe6208 auto merge of #5196 : thestinger/rust/ord, r=catamorphism
This allows `TreeMap`/`TreeSet` to fully express their requirements and reduces the comparisons from ~1.5 per level to 1 which really helps for string keys.

I also added `ReverseIter` to the prelude exports because I forgot when I originally added it.
2013-03-02 05:15:39 -08:00
Daniel Micay
035233a259 treemap: reimplement using TotalOrd 2013-03-02 14:10:19 -05:00
Daniel Micay
ca1ceb15b1 add a TotalOrd trait 2013-03-02 14:10:16 -05:00
Brian Anderson
bcf626812b Rename core::private to core::unstable. #4743 2013-03-01 14:55:47 -08:00
Brian Anderson
dab6a85230 core: Extract comm from pipes. #4742 2013-02-21 17:36:54 -08:00
Marvin Löbel
3792eb2a38 Moved core::extfmt to core::private::extfmt
Needs a snapshot to remove stage0 extfmt export in core
2013-02-21 13:32:20 +01:00
Patrick Walton
216e85fadf libcore: Move the numeric operations out of Num. r=brson
Sadly I could not use trait inheritance due to a type parameter substitution
bug.
2013-02-14 08:14:01 -08:00
bors
6727c6fb56 auto merge of #4881 : bjz/rust/incoming, r=catamorphism 2013-02-12 16:22:58 -08:00
Brendan Zabarauskas
48b2141b83 Add NumCast trait for generic numeric type casts 2013-02-11 12:33:05 +11:00
Zack Corr
4f843763a1 core: Remove GenericChan/Port from prelude. Closes #4762 2013-02-10 18:10:09 +10:00