summary refs log tree commit diff
path: root/src/libcore/num
AgeCommit message (Collapse)AuthorLines
2017-11-14Fixed several pulldown warnings when documenting libstd.kennytm-1/+1
2017-11-05Auto merge of #44042 - LukasKalbertodt:ascii-methods-on-instrinsics, ↵bors-0/+644
r=alexcrichton Copy all `AsciiExt` methods to the primitive types directly in order to deprecate it later **EDIT:** [this PR is ready now](https://github.com/rust-lang/rust/pull/44042#issuecomment-333883548). I edited this post to reflect the current status of discussion, which is (apart from code review) pretty much settled. --- This is my current progress in order to prepare stabilization of #39658. As discussed there (and in #39659), the idea is to deprecated `AsciiExt` and copy all methods to the type directly. Apparently there isn't really a reason to have those methods in an extension trait¹. ~~This is **work in progress**: copy&pasting code while slightly modifying the documentation isn't the most exciting thing to do. Therefore I wanted to already open this WIP PR after doing basically 1/4 of the job (copying methods to `&[u8]`, `char` and `&str` is still missing) to get some feedback before I continue. Some questions possibly worth discussing:~~ 1. ~~Does everyone agree that deprecating `AsciiExt` is a good idea? Does everyone agree with the goal of this PR?~~ => apparently yes 2. ~~Are my changes OK so far? Did I do something wrong?~~ 3. ~~The issue of the unstable-attribute is currently set to 0. I would wait until you say "Ok" to the whole thing, then create a tracking issue and then insert the correct issue id. Is that ok?~~ 4. ~~I tweaked `eq_ignore_ascii_case()`: it now takes the argument `other: u8` instead of `other: &u8`. The latter was enforced by the trait. Since we're not bound to a trait anymore, we can drop the reference, ok?~~ => I reverted this, because the interface has to match the `AsciiExt` interface exactly. ¹ ~~Could it be that we can't write `impl [u8] {}`? This might be the reason for `AsciiExt`. If that is the case: is there a good reason we can't write such an impl block? What can we do instead?~~ => we couldn't at the time this PR was opened, but Simon made it possible. /cc @SimonSapin @zackw
2017-11-04Use Add::add for overflow checks instead of [rustc_inherit_overflow_checks]Scott McMurray-2/+3
2017-11-03Fix #18604: next_power_of_two should panic on overflowScott McMurray-0/+1
2017-11-03Mark several ascii methods as unstable againLukas Kalbertodt-10/+30
We don't want to stabilize them now already. The goal of this set of commits is just to add inherent methods to the four types. Stabilizing all of those methods can be done later.
2017-11-03Fix lists in doc comments for ascii methods of u8 and charLukas Kalbertodt-2/+4
2017-11-03Add missing space in match armLukas Kalbertodt-2/+2
2017-11-03Tweak documentation for `u8::eq_ignore_ascii_case()`Lukas Kalbertodt-2/+1
2017-11-03Revert signature of eq_ignore_ascii_case() to originalLukas Kalbertodt-2/+2
Since the methods on u8 directly will shadow the AsciiExt methods, we cannot change the signature without breaking everything. It would have been nice to take `u8` as argument instead of `&u8`, but we cannot break stuff! So this commit reverts it to the original `&u8` version.
2017-11-03Make ascii methods on u8 insta-stableLukas Kalbertodt-48/+16
Those methods will shadow the methods of `AsciiExt`, so if we don't make them insta-stable, everyone will hitting stability errors. It is fine adding those as stable, because they are just being moved around [according to sfackler][1]. OPEN QUESTION: this commit also stabilizes the `AsciiExt` methods that were previously feature gated by the `ascii_ctype` feature. Maybe we don't want to stablilize those yet. [1]: https://github.com/rust-lang/rust/pull/44042#issuecomment-329939279
2017-11-03Add all methods of AsciiExt to u8 directlyLukas Kalbertodt-0/+655
This is the first step in order to deprecate AsciiExt. Since this is a WIP commit, there is still some code duplication (notably the static arrays) that will be removed later.
2017-10-26Bump to 1.23 and update bootstrapAlex Crichton-4/+4
This commit updates the bootstrap compiler, bumps the version to 1.23, updates Cargo, updates books, and updates crates.io dependencies
2017-09-30Auto merge of #44936 - Mark-Simulacrum:rollup, r=Mark-Simulacrumbors-0/+12
Rollup of 15 pull requests - Successful merges: #44124, #44287, #44320, #44694, #44708, #44794, #44797, #44824, #44836, #44840, #44845, #44854, #44889, #44900, #44903 - Failed merges:
2017-09-29Rollup merge of #44287 - Eh2406:master, r=aturonMark Simulacrum-0/+12
Allow T op= &T for built-in numeric types T v2 Manually rebase of @Migi https://github.com/rust-lang/rust/pull/41336
2017-09-29Auto merge of #44174 - jimmycuadra:try-from-infallible, r=sfacklerbors-29/+21
Add blanket TryFrom impl when From is implemented. Adds `impl<T, U> TryFrom<T> for U where U: From<T>`. Removes `impl<'a, T> TryFrom<&'a str> for T where T: FromStr` (originally added in #40281) due to overlapping impls caused by the new blanket impl. This removal is to be discussed further on the tracking issue for TryFrom. Refs #33417. /cc @sfackler, @scottmcm (thank you for the help!), and @aturon
2017-09-29Fix more TryFrom impls for integers.Jimmy Cuadra-4/+4
2017-09-29Simplify implementation of From<Infallible> for TryFromIntError.Jimmy Cuadra-2/+3
2017-09-28Remove conflicting TryFrom impls on 32-bit targets.Jimmy Cuadra-2/+2
2017-09-23Add back mistakenly removed numeric conversions.Jimmy Cuadra-4/+4
2017-09-16change #![feature(const_fn)] to specific gatesAlex Burka-0/+4
2017-09-04Removed the incorrect documentation for from_strMax Comstock-1/+0
2017-09-03Manuall rebase of @Migi pull/41336Eh2406-0/+12
2017-09-01impl From<Infallible> for TryFromIntError.Jimmy Cuadra-1/+8
2017-08-31Update bootstrap compilerAlex Crichton-2/+0
This commit updates the bootstrap compiler and clears out a number of #[cfg(stage0)] annotations and related business
2017-08-30Implement TryFrom explicitly for infallible numeric conversions.Jimmy Cuadra-6/+8
See https://github.com/rust-lang/rust/pull/44174#discussion_r135982787
2017-08-29Add blanket TryFrom impl when From is implemented.Jimmy Cuadra-27/+9
Adds `impl<T, U> TryFrom<T> for U where U: From<T>`. Removes `impl<'a, T> TryFrom<&'a str> for T where T: FromStr` due to overlapping impls caused by the new blanket impl. This removal is to be discussed further on the tracking issue for TryFrom. Refs #33417.
2017-08-17Rollup merge of #43891 - Fourchaux:master, r=steveklabnikCorey Farwell-3/+3
Fix typos & us spellings Fixing some typos and non en-US spellings. (Update of PR https://github.com/rust-lang/rust/pull/42812 )
2017-08-15use field init shorthand EVERYWHEREZack M. Davis-4/+4
Like #43008 (f668999), but _much more aggressive_.
2017-08-15Fix typos & us spellingsFourchaux-3/+3
2017-08-11Fix some typosBastien Orivel-1/+1
2017-07-30Document the `from_str_radix` panicTobias Bucher-0/+4
CC #42034
2017-07-26Rollup merge of #43471 - ollie27:try_from_ints, r=nagisaMark Simulacrum-11/+14
Add missing impl and tests for int to int TryFrom impls These were missing from #43248. r? @nagisa
2017-07-25Auto merge of #43320 - alexcrichton:new-bootstrap, r=Mark-Simulacrumbors-13/+8
Bump master to 1.21.0 This commit bumps the master branch's version to 1.21.0 and also updates the bootstrap compiler from the freshly minted beta release.
2017-07-25Bump master to 1.21.0Alex Crichton-13/+8
This commit bumps the master branch's version to 1.21.0 and also updates the bootstrap compiler from the freshly minted beta release.
2017-07-25Add missing impl and tests for int to int TryFrom implsOliver Middleton-11/+14
2017-07-25Auto merge of #43325 - ollie27:overflowing_literals, r=arielb1bors-5/+1
Fix overflowing_literals lint for large f32s Float literals need to be parsed as the correct type so they can be rounded correctly.
2017-07-25Auto merge of #43248 - llogiq:num-try-from, r=nagisabors-38/+177
improve the TryFrom implementations This removes the need for a 128 bit storage by making use of the fact that there can be either no over/underflow, either one or both, and each time the target type suffices to hold the limit for comparison. This also means that the implementation will work in targets without 128bit support (unless it's for 128bit types, of course). The downside is that the code looks a bit more complex.
2017-07-24improve the TryFrom implementationsAndre Bogus-38/+177
This removes the need for a 128 bit storage by making use of the fact that there can be either no over/underflow, either one or both, and each time the target type suffices to hold the limit for comparison. The downside is that the code looks a bit more complex. This test code included in this commit is from @oyvindln 's PR. They also greatly helped fixing a number of errors I made along the way. Thanks a lot!
2017-07-20std: Cut down #[inline] annotations where not necessaryAlex Crichton-37/+37
This PR cuts down on a large number of `#[inline(always)]` and `#[inline]` annotations in libcore for various core functions. The `#[inline(always)]` annotation is almost never needed and is detrimental to debug build times as it forces LLVM to perform inlining when it otherwise wouldn't need to in debug builds. Additionally `#[inline]` is an unnecessary annoation on almost all generic functions because the function will already be monomorphized into other codegen units and otherwise rarely needs the extra "help" from us to tell LLVM to inline something. Overall this PR cut the compile time of a [microbenchmark][1] by 30% from 1s to 0.7s. [1]: https://gist.github.com/alexcrichton/a7d70319a45aa60cf36a6a7bf540dd3a
2017-07-19Fix overflowing_literals lint for large f32sOliver Middleton-5/+1
Float literals need to be parsed as the correct type so they can be rounded correctly.
2017-06-28Auto merge of #42431 - nagisa:core-float-2, r=alexcrichtonbors-12/+24
Fix NaN handling in is_sign_negative/positive This would be my proposed fix for the #42425 provided we decide it is indeed a problem. Note this would technically be a breaking change to a stable API. We might want to consider deprecating these methods and adding new ones.
2017-06-22Fix NaN handling in is_sign_negative/positiveSimonas Kazlauskas-12/+24
See #42425
2017-06-16Auto merge of #42430 - nagisa:core-float, r=alexcrichtonbors-0/+63
Re-implement float min/max in rust This also adds the relevant implementations into libcore. See #42423
2017-06-14Re-implement float min/max in rustSimonas Kazlauskas-0/+63
See #42423
2017-06-08Use ctlz_nonzero to improve ASM from next_power_of_twoScott McMurray-1/+16
2017-06-08Auto merge of #40706 - irfanhudda:doc-next-power-of-two, r=alexcrichtonbors-11/+27
Improve documentation of next_power_of_two Clarify overflow behavior of `next_power_of_two`. Related Issue: #18604
2017-05-31Simplify helper functionsIrfan Hudda-15/+13
Based on @scottmcm 's suggestion
2017-05-23Add comments to explain helper functionsIrfan Hudda-5/+13
2017-05-20Auto merge of #42111 - ollie27:stab, r=Mark-Simulacrumbors-45/+45
Correct some stability versions These were found by running tidy on stable versions of rust and finding features stabilised with the wrong version numbers.
2017-05-20Correct some stability versionsOliver Middleton-45/+45
These were found by running tidy on stable versions of rust and finding features stabilised with the wrong version numbers.