summary refs log tree commit diff
path: root/src/libcore/num
AgeCommit message (Collapse)AuthorLines
2018-04-21Revert "Stabilize the TryFrom and TryInto traits"Felix S. Klock II-6/+6
This reverts commit e53a2a72743810e05f58c61c9d8a4c89b712ad2e.
2018-03-30Deprecate signed std::num::NonZeroI* with a call for use casesSimon Sapin-7/+23
2018-03-27Remove TryFrom impls that might become conditionally-infallible with a ↵Simon Sapin-60/+10
portability lint https://github.com/rust-lang/rust/pull/49305#issuecomment-376293243
2018-03-26Stabilize the TryFrom and TryInto traitsSimon Sapin-7/+7
Tracking issue: https://github.com/rust-lang/rust/issues/33417
2018-03-26Don’t use `type Error = !` for target-dependant TryFrom impls.Simon Sapin-1/+1
Instead, expose apparently-fallible conversions in cases where the implementation happens to be infallible for a given target. Having an associated type / return type in a public API change based on the target is a portability hazard.
2018-03-26TryFrom for integers: use From instead for truely-infallible implsSimon Sapin-9/+20
There is precendent in C for having a minimum pointer size, but I don’t feel confident enough about the future to mandate a maximum.
2018-03-26fix last two tidyMark Mansi-7/+1
2018-03-26Fix a few moreMark Mansi-2/+2
2018-03-26Fix missed i128 feature gatesMark Mansi-12/+12
2018-03-26Stabilize i128 feature tooMark Mansi-11/+4
2018-03-26Stabilize i128_typeMark Mansi-4/+2
2018-03-23Rollup merge of #48265 - SimonSapin:nonzero, r=KodrAusAlex Crichton-0/+89
Add 12 num::NonZero* types for primitive integers, deprecate core::nonzero RFC: https://github.com/rust-lang/rfcs/pull/2307 Tracking issue: ~~https://github.com/rust-lang/rust/issues/27730~~ https://github.com/rust-lang/rust/issues/49137 Fixes https://github.com/rust-lang/rust/issues/27730
2018-03-22Rollup merge of #49038 - canndrew:replace-infallible-with-never, r=SimonSapinkennytm-9/+8
replace `convert::Infallible` with `!`
2018-03-19Fix trailing whitespacePhlosioneer-1/+1
2018-03-19Make Wrapping::pow use wrapping_pow, add examplePhlosioneer-4/+14
2018-03-19Impl Integer methods for WrappingPhlosioneer-0/+299
Wrapping<T> now implements: count_ones, count_zeros, leading_zeros, trailing_zeros, rotate_left, rotate_right, swap_bytes, from_be, from_le, to_be, to_le, and pow where T is: u8, u16, u32, u64, usize, i8, i16, i32, i64, or isize. Docs were written for all these methods, as well as examples. The examples mirror the ones on u8, u16, etc... for consistency. Closes #32463
2018-03-18num::NonZero* types now have their own tracking issue: #49137Simon Sapin-2/+2
Fixes #27730
2018-03-17Deprecate core::nonzero in favor of ptr::NonNull and num::NonZero*Simon Sapin-1/+3
2018-03-17Add 12 num::NonZero* types for each primitive integerSimon Sapin-0/+87
RFC: https://github.com/rust-lang/rfcs/pull/2307
2018-03-16Add From<!> for TryFromIntErrorAndrew Cann-0/+7
2018-03-15replace `convert::Infallible` with `!`Andrew Cann-13/+5
2018-03-08Rollup merge of #48738 - Songbird0:parseinterror_potential_cause, r=joshtriplettManish Goregaokar-0/+7
Add a potential cause raising `ParseIntError`. Initially, I wanted to add it directly to the documentation of `str. parse()` method, I finally found that it was more relevant (I hope so?) to directly document the structure in question. I've added a scenario, in which we could all get caught at least once, to make it easier to diagnose the problem when parsing integers.
2018-03-06Add reverse_bits to integer typesAmanieu d'Antras-0/+54
2018-03-05Fix spelling error for `whitespaces`.Songbird0-1/+1
2018-03-05Modify wording and remove useless whitespaces.Songbird0-3/+3
2018-03-04Tidy error: add a new lineSongbird0-1/+2
The error was: ``` [00:05:25] tidy error: /checkout/src/libcore/num/mod.rs:3848: trailing whitespace [00:05:25] tidy error: /checkout/src/libcore/num/mod.rs:3851: line longer than 100 chars [00:05:25] tidy error: /checkout/src/libcore/num/mod.rs:3851: trailing whitespace [00:05:26] some tidy checks failed ``` The line was truncated to 92 characters.
2018-03-04Add a potential cause raising `ParseIntError`.Songbird0-0/+6
Initially, I wanted to add it directly to the documentation of `str. parse()' method, I finally found that it was more relevant (I hope so?) to directly document the structure in question. I've added a scenario, in which we could all get caught at least once, to make it easier to diagnose the problem when parsing integers.
2018-02-28Rollup merge of #48321 - milesand:no_panic_pow, r=alexcrichtonkennytm-0/+308
Add non-panicking variants of pow for integer types Currently, calling pow may panic in case of overflow, and the function does not have non-panicking counterparts. Thus, it would be beneficial to add those in. Closes #48291. Relevant tracking issue: #48320
2018-02-25Rollup merge of #48235 - varkor:parse-float-lonely-exponent, r=alexcrichtonkennytm-1/+2
Make ".e0" not parse as 0.0 This forces floats to have either a digit before the separating point, or after. Thus `".e0"` is invalid like `"."`, when using `parse()`. Fixes #40654. As mentioned in the issue, this is technically a breaking change... but clearly incorrect behaviour at present.
2018-02-24Fixes docs for ASCII functions to no longer claim U+0021 is '@'.Nathan Ringo-1/+1
2018-02-21Take 2^5 as examples in document of pow() (fixes #48396)Hidehito Yabuuchi-2/+2
Current document takes 2^4, which is equal to 4^2. This example is not very helpful for those unfamiliar with math words in English and thus rely on example codes.
2018-02-19Make ".e0" not parse as 0.0varkor-1/+2
This forces floats to have either a digit before the separating point, or after. Thus ".e0" is invalid like ".", when using `parse()`.
2018-02-19Add non-panicking variants of pow to all integer typesJewoo Lee-0/+308
Currently, calling pow may panic in case of overflow, and the function does not have non-panicking counterparts. Thus, it would be beneficial to add those in.
2018-02-17Rollup merge of #48152 - antoyo:primitive-docs-relevant, r=QuietMisdreavusGuillaume Gomez-1671/+1914
Primitive docs relevant This fixes the documentation to show the right types in the examples for many integer methods. I need to check if the result is correct before we merge.
2018-02-16Notify users that this example is shared through integer typesGuillaume Gomez-19/+47
2018-02-14Add missing featureGuillaume Gomez-218/+270
2018-02-12Fix tidy errorsAntoni Boucher-6/+10
2018-02-11Make primitive types docs relevant (unsigned)Antoni Boucher-735/+815
2018-02-11Make primitive types docs relevantGuillaume Gomez-937/+1016
2018-02-10Correct a few stability attributesOliver Middleton-3/+3
2018-02-01Use constant for 180/π in to_degreesvarkor-1/+6
The current `f32|f64.to_degrees` implementation uses a division to calculate 180/π, which causes a loss of precision. Using a constant is still not perfect (implementing a maximally-precise algorithm would come with a high performance cost), but improves precision with a minimal change.
2018-01-24Auto merge of #46931 - clarcharr:float_bits_core, r=alexcrichtonbors-50/+69
Expose float from_bits and to_bits in libcore. These methods have no dependencies on libm and thus should be offered in libcore.
2018-01-07Rollup merge of #46947 - tspiteri:checked-div-rem-none, r=frewsxcvkennytm-4/+4
doc: improve None condition doc for `checked_div` and `checked_rem` This commit improves the condition mentioned in the docs for which `checked_div` and `checked_rem` return `None`. For signed division, the commit changes "the operation results in overflow" to "the division results in overflow", otherwise there is room for misinterpretation for `checked_rem`: Without considering overflow, `MIN % -1` would be simply zero, allowing the misinterpretation that "the operation" does not result in overflow in this case. This ambiguity is removed using "when the division results in overflow". For unsigned division, the condition for `None` should be simply when `rhs == 0`, as no other overflow is possible.
2017-12-30Optimise min/maxvarkor-4/+4
Swapping the conditions generates more efficient x86 assembly. See https://github.com/rust-lang/rust/pull/46926#issuecomment-354567412.
2017-12-26Rollup merge of #46986 - nvzqz:basic-usage, r=steveklabnikkennytm-0/+8
Add "Basic Usage" to int min_value and max_value docs This adds "Basic Usage:" to the docs of `min_value` and `max_value`, which makes it consistent with docs of other integer methods.
2017-12-26Rollup merge of #46933 - clarcharr:float_docs, r=steveklabnikkennytm-2/+12
Make core::f32/f64 docs match std. For some reason these weren't in sync.
2017-12-24Add "Basic Usage" to int min_value, max_value docsNikolai Vazquez-0/+8
2017-12-23Move Bits constraints to RawFloat::RawBitsClar Charr-5/+20
2017-12-22Expose float from_bits and to_bits in libcore.Clar Charr-47/+51
2017-12-22doc: improve None condition doc for `checked_div` and `checked_rem`Trevor Spiteri-4/+4