Commit Graph

123 Commits

Author SHA1 Message Date
bors fd2488bf5a auto merge of #9051 : bjz/rust/master, r=huonw 2013-09-09 06:06:04 -07:00
bors dd5c7379e9 auto merge of #8988 : cmr/rust/fromstr_fn, r=brson
It just calls out to the associated function on the trait.
2013-09-08 12:05:55 -07:00
Corey Richardson e0e5523552 Fix import order which caused the wrong from_str to be in scope 2013-09-08 15:00:00 -04:00
Brendan Zabarauskas 2c31053d20 Fix unused import warnings on 32bit systems 2013-09-09 03:51:29 +10:00
Brendan Zabarauskas 8445009a84 Add Clone and DeepClone constraints to Primitive trait 2013-09-08 13:48:46 +10:00
Brendan Zabarauskas 0fcb85997d Moved checked trait impls out of std::num
This follows the same pattern as the other numeric trait impls, and reduces the clutter in std::num.
2013-09-08 13:48:15 +10:00
bors 25f3b29c61 auto merge of #9010 : aaronlaursen/rust/master, r=alexcrichton
Here's a fix for issue #7588, "Overflow handling of from_str methods is broken". 

The integer overflow issues are taken care of by checking to see if the multiply-by-radix-and-add-next-digit process is reversible. If it overflowed, then some information is lost and the process is irreversible, in which case, None is returned. 

Floats now consistently return Some(Inf) of Some(-Inf) on overflow thanks to a call to NumStrConv::inf() and NumStrConv::neg_inf() respectively when the overflow is detected (which yields a value of None in the case of ints and uints anyway). 

This is my first contribution to Rust, and my first time using the language in general, so any and all feedback is appreciated.
2013-09-06 20:10:57 -07:00
Aaron Laursen caf5321eb4 fix for issue #7588, overflow now handled correctly 2013-09-06 13:00:34 -05:00
Florian Hahn de39874801 Rename str::from_bytes to str::from_utf8, closes #8985 2013-09-05 14:17:24 +02:00
bors bb35e23f1c auto merge of #8896 : lightcatcher/rust/default_eq_fix, r=thestinger
Summary:
-removed "ne" methods in libstd and librustpkg
-made default "ne" be inlined
-made one of the "eq" methods in librustpkg follow more standard parameter naming convention
2013-08-30 21:40:32 -07:00
Eric Martin babe20f018 remove several 'ne' methods 2013-08-30 21:53:25 -04:00
Erick Tryzelaar 9730ed9b02 std: Add a fixme for when we add Trait::<for T>::static_method() 2013-08-30 15:10:55 -07:00
bors ed422b8872 auto merge of #8819 : vadimcn/rust/unit-tests, r=brson
Some of the tests are failing.  I've only managed to fix 'memory_map_file', the rest are up for grabs...

Fixes #5261.
2013-08-29 20:40:47 -07:00
Jason Fager dc30005ad8 Remove the iter module.
Moves the Times trait to num while the question of whether it should
exist at all gets hashed out as a completely separate question.
2013-08-29 01:27:24 -04:00
Vadim Chugunov 6828428cad Disabled failing parts of abs_sub() and frexp() unit tests on Windows. 2013-08-28 01:44:12 -07:00
Patrick Walton 8693943676 librustc: Ensure that type parameters are in the right positions in paths.
This removes the stacking of type parameters that occurs when invoking
trait methods, and fixes all places in the standard library that were
relying on it. It is somewhat awkward in places; I think we'll probably
want something like the `Foo::<for T>::new()` syntax.
2013-08-27 18:47:57 -07:00
Vadim Chugunov 12ecdb6381 Enabled unit tests in std and extra. 2013-08-22 20:02:20 -07:00
bors e66478193b auto merge of #8610 : kballard/rust/mod_floor, r=alexcrichton
`mod_floor()` was incorrectly defined for uint types as `a / b` instead of `a % b`.
2013-08-21 09:31:43 -07:00
Daniel Micay 0ba8ccdaee rm obsolete float to_str_radix free functions 2013-08-20 22:05:03 -04:00
Daniel Micay 46fc549fa9 rm obsolete integer to_str{,_radix} free functions 2013-08-20 22:05:03 -04:00
bors 4bdceb9c00 auto merge of #8459 : thestinger/rust/checked, r=graydon 2013-08-19 12:42:48 -07:00
Niko Matsakis 0479d946c8 Add externfn macro and correctly label fixed_stack_segments 2013-08-19 07:13:15 -04:00
Kevin Ballard ac3bc9cfcc Fix mod_floor() for uint primitive types 2013-08-19 01:01:11 -07:00
Huon Wilson abe94f9b4d doc: correct spelling in documentation. 2013-08-16 15:41:28 +10:00
Kevin Ballard 15159a5638 Rewrite Saturating in terms of CheckedAdd/CheckedSub 2013-08-14 13:02:20 -07:00
Alex Crichton 930885d5e5 Forbid pub/priv where it has no effect
Closes #5495
2013-08-12 23:20:46 -07:00
Daniel Micay 0cb0ef2ca5 fix build with the new snapshot compiler 2013-08-12 17:37:46 -04:00
Daniel Micay b244911398 num: implement CheckedDiv 2013-08-11 19:19:19 -04:00
Daniel Micay 7db605cd15 disable 64-bit CheckedMul on 32-bit
code generation problem reported as issue #8449
2013-08-11 02:58:52 -04:00
Daniel Micay 076b91f8ad add intrinsics for checked overflow add/sub/mul 2013-08-11 02:51:20 -04:00
OGINO Masanori b4d6ae5bb8 Remove redundant Ord method impls.
Basically, generic containers should not use the default methods since a
type of elements may not guarantees total order. str could use them
since u8's Ord guarantees total order. Floating point numbers are also
broken with the default methods because of NaN. Thanks for @thestinger.

Timespec also guarantees total order AIUI. I'm unsure whether
extra::semver::Identifier does so I left it alone. Proof needed.

Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
2013-08-09 14:28:14 +09:00
Huon Wilson 8460dac909 std: add missing #[inline] annotation to the f64 arithmetic trait impls. 2013-08-07 22:41:14 -04:00
Alex Crichton e99eff172a Forbid priv where it has no effect
This is everywhere except struct fields and enum variants.
2013-08-07 22:41:12 -04:00
Kevin Ballard 8964fcc5ac Implement DoubleEndedIterator on Range
Range is now invertable as long as its element type conforms to Integer.

Remove int::range_rev() et al in favor of range().invert().
2013-08-07 22:41:09 -04:00
bors 54c8c23d05 auto merge of #8323 : kballard/rust/saturating, r=thestinger
Implement saturating math in `std::num::Saturating` and use it for `Iterator` impls
2013-08-07 04:02:16 -07:00
Kevin Ballard 5f713da4aa Add std::num::Saturating
Saturating is an implementation of saturating math operations (at the
moment just add and sub) for integral types.
2013-08-05 22:49:33 -07:00
blake2-ppc ea9c5c405e std: Remove uint::iterate, replaced by range 2013-08-06 04:05:08 +02:00
Marvin Löbel 0ac7a219f0 Updated std::Option, std::Either and std::Result
- Made naming schemes consistent between Option, Result and Either
- Changed Options Add implementation to work like the maybe monad (return None if any of the inputs is None)
- Removed duplicate Option::get and renamed all related functions to use the term `unwrap` instead
2013-08-05 22:42:21 +02:00
Daniel Micay b3ad685f7f replace all remaining for with foreach or do 2013-08-03 03:00:42 -04:00
Patrick Walton 9457ebee55 librustc: Disallow "unsafe" for external functions 2013-08-02 21:57:59 -07:00
Daniel Micay 234acad404 replace range with an external iterator 2013-08-02 00:51:14 -04:00
blake2-ppc 78cde5b9fb std: Change Times trait to use do instead of for
Change the former repetition::

    for 5.times { }

to::

    do 5.times { }

.times() cannot be broken with `break` or `return` anymore; for those
cases, use a numerical range loop instead.
2013-08-01 16:54:22 +02:00
Brendan Zabarauskas 4f65fc7ef2 Improve std::num module description, and fix some formatting 2013-07-30 08:59:43 +10:00
Brendan Zabarauskas b6ea0538a9 Add some missing method wrappers to std::num 2013-07-30 08:58:46 +10:00
Birunthan Mohanathas d047cf1ec6 Change 'print(fmt!(...))' to printf!/printfln! in src/lib* 2013-07-24 09:45:20 -04:00
Graydon Hoare 9f7e364d3a std: add #[bench] benchmarks for num::strconv 2013-07-22 16:56:11 -07:00
Patrick Walton 06594ed96b librustc: Remove pub extern and priv extern from the language.
Place `pub` or `priv` on individual items instead.
2013-07-20 17:39:38 -07:00
bors 5c999d4eca auto merge of #7894 : pcwalton/rust/and-pointers-in-at-boxes, r=brson
r? @brson
2013-07-20 10:55:34 -07:00
Brian Anderson ddd8c156c6 std: Remove old magic core mod 2013-07-19 21:01:24 -04:00
Patrick Walton 9089cf2ec9 librustc: Forbid & pointers (other than &'static) inside @ boxes.
This makes custom borrowing implementations for custom smart pointers
sound.
2013-07-18 17:12:46 -07:00