about summary refs log tree commit diff
path: root/src/libcore/num
AgeCommit message (Collapse)AuthorLines
2015-04-21std: Bring back f32::from_str_radix as an unstable APIAlex Crichton-237/+173
This API was exercised in a few tests and mirrors the `from_str_radix` functionality of the integer types.
2015-04-21std: Remove deprecated/unstable num functionalityAlex Crichton-1691/+103
This commit removes all the old casting/generic traits from `std::num` that are no longer in use by the standard library. This additionally removes the old `strconv` module which has not seen much use in quite a long time. All generic functionality has been supplanted with traits in the `num` crate and the `strconv` module is supplanted with the [rust-strconv crate][rust-strconv]. [rust-strconv]: https://github.com/lifthrasiir/rust-strconv This is a breaking change due to the removal of these deprecated crates, and the alternative crates are listed above. [breaking-change]
2015-04-21Model lexer: Fix remaining issuesPiotr Czarnecki-2/+0
2015-04-17side-step potentially panic'ing negate in `fn abs`.Felix S. Klock II-1/+5
2015-04-17Auto merge of #24420 - pnkfelix:oflo-api, r=alexcrichtonbors-1/+156
Fill in missing parts of Integer overflow API See todo list at #22020
2015-04-14Fix bug in `wrapping_div`Felix S. Klock II-1/+1
See discussion, albeit one-sided, in: https://github.com/rust-lang/rfcs/issues/964
2015-04-14Remaining API additions for int overflow:Felix S. Klock II-0/+155
`wrapping_div`, `wrapping_rem`, `wrapping_neg`, `wrapping_shl`, `wrapping_shr`. All marked unstable under `core` feature for now (with expectation of being marked as stable by 1.0 release).
2015-04-13pluralize doc comment verbs and add missing periodsAndrew Paseltiner-43/+43
2015-04-12mod.rs documentary fixIgor Strebezhev-2/+2
Docs meant that Option is returned though the function returns Result.
2015-04-11Rollup merge of #24298 - White-Oak:master, r=alexcrichtonManish Goregaokar-11/+8
Fixes 'fn from_str_radix' documentation where docs meant that Option is returned, though the function returns Result.
2015-04-11Rollup merge of #24291 - xamgore:patch-1, r=steveklabnikManish Goregaokar-6/+6
From [here](http://doc.rust-lang.org/nightly/std/primitive.i8.html): > `fn rotate_right(self, n: u32) -> i8` > Shifts the bits to the right by a specified __amount amount__, n, wrapping the truncated bits to the beginning of the resulting integer.
2015-04-11Rollup merge of #24274 - steveklabnik:fix_pow_docs, r=nikomatsakisManish Goregaokar-4/+3
This is very confusing now that these are inherent methods.
2015-04-10mod.rs docs fix - for floatsOak-5/+4
Same with integers — docs meant that Option is returned though the function returns Result.
2015-04-10mod.rs docs fixOak-6/+4
Docs meant that Option is returned though the function returns Result.
2015-04-10Fix mistake in documentationIgor Strebezhev-6/+6
2015-04-10Auto merge of #24177 - alexcrichton:rustdoc, r=aturonbors-0/+1
This commit series starts out with more official test harness support for rustdoc tests, and then each commit afterwards adds a test (where appropriate). Each commit should also test and finish independently of all others (they're all pretty separable). I've uploaded a [copy of the documentation](http://people.mozilla.org/~acrichton/doc/std/) generated after all these commits were applied, and a double check on issues being closed would be greatly appreciated! I'll also browse the docs a bit and make sure nothing regressed too horribly.
2015-04-10Fix pow docs to not use IntSteve Klabnik-4/+3
This is very confusing now that these are inherent methods.
2015-04-07std: Hide facade extension traits in docsAlex Crichton-0/+1
These traits are currently all just unstable parts of the facade which are implementation details for primitives further up the facade. This may make it more difficult to find what set of methods you get if only linking to libcore, but for now that's also unstable behavior. Closes #22025
2015-04-08Make `sum` and `product` inherent methods on `Iterator`Tobias Bucher-0/+14
In addition to being nicer, this also allows you to use `sum` and `product` for iterators yielding custom types aside from the standard integers. Due to removing the `AdditiveIterator` and `MultiplicativeIterator` trait, this is a breaking change. [breaking-change]
2015-04-03Auto merge of #23832 - petrochenkov:usize, r=aturonbors-4/+4
These constants are small and can fit even in `u8`, but semantically they have type `usize` because they denote sizes and are almost always used in `usize` context. The change of their type to `u32` during the integer audit led only to the large amount of `as usize` noise (see the second commit, which removes this noise). This is a minor [breaking-change] to an unstable interface. r? @aturon
2015-04-01Test fixes and rebase conflicts, round 2Alex Crichton-1/+1
2015-04-01rollup merge of #23860: nikomatsakis/copy-requires-cloneAlex Crichton-1/+1
Conflicts: src/test/compile-fail/coherence-impls-copy.rs
2015-04-01rollup merge of #23945: pnkfelix/gate-u-negateAlex Crichton-4/+50
Feature-gate unsigned unary negate. Discussed in weekly meeting here: https://github.com/rust-lang/meeting-minutes/blob/master/weekly-meetings/2015-03-31.md#feature-gate--expr and also in the internals thread here: http://internals.rust-lang.org/t/forbid-unsigned-integer/752
2015-04-01Fix bug in `OverflowOps` impl for unsigned integers.Felix S. Klock II-3/+49
Namely, the special case treatment for `div`/`rem` is only applicable to signed integer values. Clearly RFC 1027 would have saved us here! ;)
2015-04-01fallout from feature-gating unary negation on unsigned integers.Felix S. Klock II-1/+1
2015-04-01rollup merge of #23947: aturon/revise-numAlex Crichton-0/+20
Recent numerics stabilization removed the inherent `min_value` and `max_value` methods from integer types, assuming that the module-level constants would suffice. However, that failed to account for the use case in FFI code when dealing with integer type aliases. This commit reintroduces the methods as `#[stable]`, since this is essential functionality for 1.0. It's unfortunate to freeze these as methods, but when we can provide inherent associated constants these methods can be deprecated. r? @sfackler cc @alexcrichton
2015-04-01Re-add min_value, max_value methodsAaron Turon-0/+20
Recent numerics stabilization removed the inherent `min_value` and `max_value` methods from integer types, assuming that the module-level constants would suffice. However, that failed to account for the use case in FFI code when dealing with integer type aliases. This commit reintroduces the methods as `#[stable]`, since this is essential functionality for 1.0. It's unfortunate to freeze these as methods, but when we can provide inherent associated constants these methods can be deprecated.
2015-04-01Collect the definition of the `Error` trait into `libstd` for now. ThisNiko Matsakis-21/+20
sidesteps a coherence difficulty where `liballoc` had to prove that `&str: !Error`, which didn't involve any local types.
2015-04-01Fallout in public-facing and semi-public-facing libsNiko Matsakis-1/+1
2015-03-31rollup merge of #23863: pnkfelix/arith-oflo-const-evalAlex Crichton-0/+130
const_eval : add overflow-checking for {`+`, `-`, `*`, `/`, `<<`, `>>`}. One tricky detail here: There is some duplication of labor between `rustc::middle::const_eval` and `rustc_trans::trans::consts`. It might be good to explore ways to try to factor out the common structure to the two passes (by abstracting over the particular value-representation used in the compile-time interpreter). ---- Update: Rebased atop #23841 Fix #22531 Fix #23030 Fix #23221 Fix #23235
2015-04-01Added overflowing_{div,rem,shl,shr} method implementations to WrappingOps.Felix S. Klock II-0/+130
2015-03-31Test fixes and rebase conflicts, round 2Alex Crichton-1/+1
2015-03-31Stabilize std::numAaron Turon-200/+394
This commit stabilizes the `std::num` module: * The `Int` and `Float` traits are deprecated in favor of (1) the newly-added inherent methods and (2) the generic traits available in rust-lang/num. * The `Zero` and `One` traits are reintroduced in `std::num`, which together with various other traits allow you to recover the most common forms of generic programming. * The `FromStrRadix` trait, and associated free function, is deprecated in favor of inherent implementations. * A wide range of methods and constants for both integers and floating point numbers are now `#[stable]`, having been adjusted for integer guidelines. * `is_positive` and `is_negative` are renamed to `is_sign_positive` and `is_sign_negative`, in order to address #22985 * The `Wrapping` type is moved to `std::num` and stabilized; `WrappingOps` is deprecated in favor of inherent methods on the integer types, and direct implementation of operations on `Wrapping<X>` for each concrete integer type `X`. Closes #22985 Closes #21069 [breaking-change]
2015-03-30Change the type of constants BYTES/BITS to usizeVadim Petrochenkov-4/+4
2015-03-28Remove IteratorExtSteven Fackler-1/+1
All methods are inlined into Iterator with `Self: Sized` bounds to make sure Iterator is still object safe. [breaking-change]
2015-03-27rollup merge of #23741: alexcrichton/remove-int-uintAlex Crichton-66/+68
Conflicts: src/librustc/middle/ty.rs src/librustc_trans/trans/adt.rs src/librustc_typeck/check/mod.rs src/libserialize/json.rs src/test/run-pass/spawn-fn.rs
2015-03-27rollup merge of #23780: ruud-v-a/wrappingAlex Crichton-1/+1
This allows `Wrapping<T>` to be used in `assert_eq!`, for example. One of the tests (compile-fail/xc-private-method.rs) fails, but I can hardly imagine it is related to this change. I would also like to add a tests to ensure that `assert_eq!` compiles and keeps working in the future for `Wrapped<T>` values, but there appear to be no tests in libcore. What would be a good place to add such a test?
2015-03-27num: Derive Debug for WrappingRuud van Asseldonk-1/+1
This allows `Wrapping<T>` to be used in `assert_eq!`, for example.
2015-03-27Change the trivial cast lints to allow by defaultNick Cameron-13/+0
2015-03-26Mass rename uint/int to usize/isizeAlex Crichton-66/+68
Now that support has been removed, all lingering use cases are renamed.
2015-03-25Change lint names to pluralsNick Cameron-13/+13
2015-03-25Add trivial cast lints.Nick Cameron-0/+13
This permits all coercions to be performed in casts, but adds lints to warn in those cases. Part of this patch moves cast checking to a later stage of type checking. We acquire obligations to check casts as part of type checking where we previously checked them. Once we have type checked a function or module, then we check any cast obligations which have been acquired. That means we have more type information available to check casts (this was crucial to making coercions work properly in place of some casts), but it means that casts cannot feed input into type inference. [breaking change] * Adds two new lints for trivial casts and trivial numeric casts, these are warn by default, but can cause errors if you build with warnings as errors. Previously, trivial numeric casts and casts to trait objects were allowed. * The unused casts lint has gone. * Interactions between casting and type inference have changed in subtle ways. Two ways this might manifest are: - You may need to 'direct' casts more with extra type information, for example, in some cases where `foo as _ as T` succeeded, you may now need to specify the type for `_` - Casts do not influence inference of integer types. E.g., the following used to type check: ``` let x = 42; let y = &x as *const u32; ``` Because the cast would inform inference that `x` must have type `u32`. This no longer applies and the compiler will fallback to `i32` for `x` and thus there will be a type error in the cast. The solution is to add more type information: ``` let x: u32 = 42; let y = &x as *const u32; ```
2015-03-23Add #![feature] attributes to doctestsBrian Anderson-2/+26
2015-03-20Auto merge of #23254 - jbcrail:saturating-math-docs, r=steveklabnikbors-0/+20
This was added for #23241.
2015-03-18Register new snapshotsAlex Crichton-974/+954
2015-03-17Rollup merge of #23385 - tamird:cleanup-whitespace, r=alexcrichtonManish Goregaokar-1/+0
r? @alexcrichton Conflicts: src/test/run-pass/test-fn-signature-verification-for-explicit-return-type.rs
2015-03-17Rollup merge of #23329 - jbcrail:rm-syntax-highlight, r=sanxiynManish Goregaokar-18/+18
As suggested by @steveklabnik in #23254, I removed the redundant Rust syntax highlighting from the documentation.
2015-03-16impl {i,u}{8,16,32,64,size}Jorge Aparicio-0/+990
2015-03-15Strip all leading/trailing newlinesTamir Duberstein-1/+0
2015-03-13Remove explicit syntax highlight from docs.Joseph Crail-18/+18