about summary refs log tree commit diff
path: root/src/libcore/num
AgeCommit message (Collapse)AuthorLines
2014-11-18auto merge of #19031 : nodakai/rust/libcore-pow-and-sq, r=bjzbors-21/+26
[breaking-change] Deprecates `core::num::pow` in favor of `Int::pow`.
2014-11-18libcore: add num::Int::pow() and deprecate num::pow().NODA, Kai-21/+26
Signed-off-by: NODA, Kai <nodakai@gmail.com>
2014-11-18rollup merge of #19015: alex/libcore-typosJakub Bukaj-2/+2
2014-11-18rollup merge of #18911: canndrew/slice_shift_charJakub Bukaj-11/+11
`slice_shift_char` splits a `str` into it's leading `char` and the remainder of the `str`. Currently, it returns a `(Option<char>, &str)` such that: "bar".slice_shift_char() => (Some('b'), "ar") "ar".slice_shift_char() => (Some('a'), "r") "r".slice_shift_char() => (Some('r'), "") "".slice_shift_char() => (None, "") This is a little odd. Either a `str` can be split into both a head and a tail or it cannot. So the return type should be `Option<(char, &str)>`. With the current behaviour, in the case of the empty string, the `str` returned is meaningless - it is always the empty string. This PR changes `slice_shift_char` so that: "bar".slice_shift_char() => Some(('b', "ar")) "ar".slice_shift_char() => Some(('a', "r")) "r".slice_shift_char() => Some(('r', "")) "".slice_shift_char() => None
2014-11-17Switch to purely namespaced enumsSteven Fackler-0/+2
This breaks code that referred to variant names in the same namespace as their enum. Reexport the variants in the old location or alter code to refer to the new locations: ``` pub enum Foo { A, B } fn main() { let a = A; } ``` => ``` pub use self::Foo::{A, B}; pub enum Foo { A, B } fn main() { let a = A; } ``` or ``` pub enum Foo { A, B } fn main() { let a = Foo::A; } ``` [breaking-change]
2014-11-17change return type of slice_shift_charAndrew Cann-11/+11
`slice_shift_char` splits a `str` into it's leading `char` and the remainder of the `str`. Currently, it returns a `(Option<char>, &str)` such that: "bar".slice_shift_char() => (Some('b'), "ar") "ar".slice_shift_char() => (Some('a'), "r") "r".slice_shift_char() => (Some('r'), "") "".slice_shift_char() => (None, "") This is a little odd. Either a `str` can be split into both a head and a tail or it cannot. So the return type should be `Option<(char, &str)>`. With the current behaviour, in the case of the empty string, the `str` returned is meaningless - it is always the empty string. This commit changes slice_shift_char so that: "bar".slice_shift_char() => Some(('b', "ar")) "ar".slice_shift_char() => Some(('a', "r")) "r".slice_shift_char() => Some(('r', "")) "".slice_shift_char() => None [breaking-change]
2014-11-16Fixed a few typos in libcoreAlex Gaynor-2/+2
2014-11-16Remove core::num::strconvBrendan Zabarauskas-411/+282
2014-11-16Move FromStr to core::strBrendan Zabarauskas-2/+432
2014-11-13Remove Signed trait and add SignedInt traitBrendan Zabarauskas-116/+146
The methods have been moved into Float and SignedInt
2014-11-13Remove lots of numeric traits from the preludesBrendan Zabarauskas-0/+26
Num, NumCast, Unsigned, Float, Primitive and Int have been removed.
2014-11-13Clean up core::num doc commentsBrendan Zabarauskas-50/+45
2014-11-13Deprecate signum wrapper and clean up signed implsBrendan Zabarauskas-38/+42
2014-11-13Deprecate Num, Unsigned and PrimitiveBrendan Zabarauskas-46/+60
2014-11-13Deprecate Zero and One traitsBrendan Zabarauskas-121/+111
2014-11-13Deprecate Bounded traitBrendan Zabarauskas-57/+86
2014-11-13Move checked arithmetic operators into Int traitBrendan Zabarauskas-220/+191
2014-11-13Rejig Int impl macrosBrendan Zabarauskas-20/+32
This should make implementing the checked operator methods easier
2014-11-13Move saturating operator methods into IntBrendan Zabarauskas-37/+22
2014-11-13Create UnsignedInt trait and deprecate free functionsBrendan Zabarauskas-29/+50
2014-11-13Move abs_sub to FloatMathBrendan Zabarauskas-22/+0
This removes the need for libcore to depend on libm. `abs_sub` is not as useful for integers.
2014-11-13Deprecate Signed method wrappersBrendan Zabarauskas-19/+7
2014-11-13Take parameters by-value in Signed traitBrendan Zabarauskas-27/+27
2014-11-08Make Int inherit from Ord.Josh Haberman-1/+2
Previously Int inherited from PartialOrd (via Primitive) but not Ord. But integers have a total order, so inheriting from Ord is appropriate. Fixes #18776.
2014-10-30rollup merge of #18398 : aturon/lint-conventions-2Alex Crichton-3/+3
Conflicts: src/libcollections/slice.rs src/libcore/failure.rs src/libsyntax/parse/token.rs src/test/debuginfo/basic-types-mut-globals.rs src/test/debuginfo/simple-struct.rs src/test/debuginfo/trait-pointers.rs
2014-10-30rollup merge of #18421 : tbu-/pr_checkeddiv1Alex Crichton-1/+1
2014-10-30rollup merge of #18392 : cakebaker/remove_double_negationAlex Crichton-1/+1
2014-10-29Rename fail! to panic!Steve Klabnik-1/+1
https://github.com/rust-lang/rfcs/pull/221 The current terminology of "task failure" often causes problems when writing or speaking about code. You often want to talk about the possibility of an operation that returns a Result "failing", but cannot because of the ambiguity with task failure. Instead, you have to speak of "the failing case" or "when the operation does not succeed" or other circumlocutions. Likewise, we use a "Failure" header in rustdoc to describe when operations may fail the task, but it would often be helpful to separate out a section describing the "Err-producing" case. We have been steadily moving away from task failure and toward Result as an error-handling mechanism, so we should optimize our terminology accordingly: Result-producing functions should be easy to describe. To update your code, rename any call to `fail!` to `panic!` instead. Assuming you have not created your own macro named `panic!`, this will work on UNIX based systems: grep -lZR 'fail!' . | xargs -0 -l sed -i -e 's/fail!/panic!/g' You can of course also do this by hand. [breaking-change]
2014-10-29Fix `core::num::CheckedDiv::checked_div` documentationTobias Bucher-1/+1
The "/" was probably generated by a `gq` in vim.
2014-10-28Update code with new lint namesAaron Turon-3/+3
2014-10-28Remove double negation from sqrt's doc commentDaniel Hofstetter-1/+1
2014-10-21Correct case where the old version of method lookup was incorrectly matching,Niko Matsakis-2/+2
as far as I can tell.
2014-10-20Handle negative numbers in `sqrt` properly.Huon Wilson-3/+12
Closes #9987.
2014-10-09core: Convert statics to constantsAlex Crichton-74/+74
2014-09-17doc: Cleanup.Jonas Hietala-4/+4
Remove ~~~ for code block specification. Use /// Over /** */ for doc blocks.
2014-09-05Make integer bit count methods return uintsBrendan Zabarauskas-10/+10
Fixes rust-lang/rfcs#224
2014-08-26Added a note for usage of abs with ::MIN.Robert Gawdzik ☢-2/+6
2014-08-19auto merge of #16364 : tbu-/rust/pr_checkeddiv0, r=alexcrichtonbors-3/+5
2014-08-08Add division by zero case to the `CheckedDiv` commentTobias Bucher-3/+5
2014-08-08libcore: Fix documentation comment for f32.Ruud van Asseldonk-1/+1
2014-08-04num: Fix the documentation of abs_sub.OGINO Masanori-2/+2
Use proper argument names and unbackquote the word "zero" because it is not an identifier. Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
2014-08-01doc: fix typos in std::num::IntTshepang Lekhonkhobe-2/+2
2014-07-29Improve documentation of rounding functionsPiotr Jawniak-35/+34
2014-07-24Add examples for Checked[Add|Sub|Mul|Div]nham-0/+32
2014-07-24auto merge of #15407 : sneves/rust/master, r=aturonbors-8/+8
At the moment, writing generic functions for integer types that involve shifting is rather verbose. For example, a function at shifts an integer left by 1 currently requires use std::num::One; fn f<T: Int>(x : T) -> T { x << One::one() } If the shift amount is not 1, it's even worse: use std::num::FromPrimitive; fn f<T: Int + FromPrimitive>(x: T) -> T { x << FromPrimitive::from_int(2).unwrap() } This patch allows the much simpler implementation fn f<T: Int>(x: T) -> T { x << 2 } It accomplishes this by changing the built-in integer types (and the `Int` trait) to implement `Shl<uint, T>` instead of `Shl<T, T>` as it currently is defined. Note that the internal implementations of `shl` already cast the right-hand side to `uint`. `BigInt` also implements `Shl<uint, BigInt>`, so this increases consistency. All of the above applies similarly to right shifts, i.e., `Shr<uint, T>`.
2014-07-22Clean up some trait impls in core::num.Tobias Bucher-18/+7
This removes the special casing for `float`s where it was not necessary, as `-0.0 == 0.0`.
2014-07-21Add a ton of ignore-lexer-testCorey Richardson-0/+2
2014-07-10Add range lint for float literals, fixing #10934Falco Hirschenberger-0/+4
2014-07-08make macros non-capturingJohn Clements-67/+67
2014-07-04Change Shl<T, T> for Int to Shl<uint, T>Samuel Neves-8/+8