Björn Steinbrink
bdc182cc41
Use static string with fail!() and remove fail!(fmt!())
...
fail!() used to require owned strings but can handle static strings
now. Also, it can pass its arguments to fmt!() on its own, no need for
the caller to call fmt!() itself.
2013-05-14 16:36:23 +02:00
Alex Crichton
28256052a4
core: Use the new for
protocol
2013-05-10 02:46:18 -04:00
Zack Corr
cb66d8948a
Remove #[cfg(notest)] and use #[cfg(not(test))] to cooincide with #[cfg(debug)]
2013-05-08 21:11:23 +10:00
Brian Anderson
8081e8debf
Register snapshots
2013-05-04 15:43:51 -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
Brendan Zabarauskas
20ad931bf3
Rename 'divisible_by' method to 'is_multiple_of', add tests for 'is_odd' and 'is_even'
2013-04-29 16:03:48 +10: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
dbc2e99693
Use ///
doc-comment form instead of /** */
2013-04-26 09:55:49 +10:00
Brendan Zabarauskas
ad0b337036
Add is_zero method to Zero
2013-04-26 05:55:26 +10:00
Brendan Zabarauskas
6fa054df96
Use borrowed pointers for Integer methods
...
This brings them in line with the quot and rem traits, and is be better for large Integer types like BigInt and BigUint because they don't need to be copied unnecessarily.
2013-04-25 08:20:00 +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
03932f0b84
Move impls of Num
out of core::num and clean up imports
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
Daniel Micay
a3e33cfb6e
inline the primitive numeric operations
2013-04-23 14:05:41 -04:00
Brendan Zabarauskas
01eb5e8ad3
Rename Div operator trait to Quot and Modulo operator trait to Rem
2013-04-22 01:58:53 +10:00
Patrick Walton
c995a62d44
librustc: WIP patch for using the return value.
2013-04-19 12:00:08 -07:00
Brendan Zabarauskas
a7f6ec8542
Use assert_eq! instead of assert! and remove extraneous parentheses
2013-04-19 01:37:21 +10:00
Brendan Zabarauskas
939a97f5cb
Add #[inline(always)] to each operator method
2013-04-18 23:24:24 +10:00
Brendan Zabarauskas
d2a81b95c3
Implement bitwise operator traits for ints and uints
2013-04-18 20:58:58 +10:00
Huon Wilson
d3be98e9f5
libcore,std,syntax,rustc: move tests into mod tests
, make them private (no pub mod or pub fn).
2013-04-16 09:57:47 +10:00
Brendan Zabarauskas
c4685477e0
Consolidate tests of numeric operations
2013-04-14 02:53:00 +10:00
bors
412a07055c
auto merge of #5769 : gifnksm/rust/range_step, r=bstrie
...
`uint::range_step` or `int::range_step` causes overflow or underflow as following.
code:
```rust
fn main() {
for uint::range_step(3, 0, -2) |n| {
println(fmt!("%u", n));
}
}
```
output:
```
3
1
18446744073709551615
18446744073709551613
...
```
This commit fixes this behavior as follows.
```
3
1
```
2013-04-09 07:52:04 -07:00
Huon Wilson
41c6f67109
libcore: from_str_common: provide option to ignore underscores.
...
Implement the possible improvement listed in the comment on
from_str_bytes_common.
2013-04-08 16:35:39 +10:00
gifnksm
89676d6a59
libcore: fix overflow/underflow in range_step
2013-04-07 19:55:58 +09:00
Patrick Walton
1e91595520
librustc: Remove fail_unless!
2013-03-29 16:39:08 -07:00
Alex Crichton
be57d745d2
Removing unused imports
2013-03-28 23:56:46 -04:00
Patrick Walton
85c9fc6f8f
librustc: Remove the const
declaration form everywhere
2013-03-22 22:24:35 -07:00
Patrick Walton
be9bddd463
libcore: Remove pure
from libcore. rs=depure
2013-03-22 10:29:17 -07:00
Patrick Walton
4634f7edae
librustc: Remove all uses of static
from functions. rs=destatic
2013-03-22 10:27:39 -07:00
Patrick Walton
bd2d17e4a1
libsyntax: Stop parsing bare functions in preparation for switching them over
2013-03-11 09:35:58 -07:00
Patrick Walton
d18f785457
librustc: Replace all uses of fn()
with &fn()
. rs=defun
2013-03-11 09:35:58 -07:00
Patrick Walton
d661711cc2
test: Fix tests.
2013-03-07 22:37:58 -08:00
Patrick Walton
d7e74b5e91
librustc: Convert all uses of assert
over to fail_unless!
2013-03-07 22:37:57 -08:00
Alex Crichton
cb4ab76e4a
Adding missing imports for tests, and gate off others
2013-03-04 12:27:01 -05:00
Alex Crichton
dfb5c10dea
Remove unused imports throughout src/
2013-03-04 12:27:01 -05:00
Marvin Löbel
42b0bacd76
Removed deprecated str()
functions in int-template.rs and uint-template.rs
2013-02-26 16:38:30 +01:00
Marvin Löbel
3edc7c0b9c
Removed generic infinity, NaN and negative zero functions
...
Removed Round impl for integers
2013-02-15 05:46:07 +01:00
Marvin Löbel
bd93a36d73
Made num <-> str conversion functions use NumStrConv trait
...
Removed hacky dependency on Round trait and generic infinity functions
Removed generic-runtime-failure-depending-on-type behavior
2013-02-15 05:20:36 +01:00
Marvin Löbel
adac6cb5c6
Moved numeric string conversion functions into own module
2013-02-15 03:29:36 +01:00
Patrick Walton
9143688197
librustc: Replace impl Type : Trait
with impl Trait for Type
. rs=implflipping
2013-02-14 14:44:12 -08: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
Nick Desaulniers
4445b38df2
Remove die!, raplace invocations with fail! Issue #4524 pt 3
2013-02-13 17:01:32 -08:00
Graydon Hoare
389125aeb8
core: add min and max to cmp, re-export various places.
2013-02-13 11:46:25 -08:00