about summary refs log tree commit diff
path: root/src/libcore/convert
AgeCommit message (Collapse)AuthorLines
2020-07-27mv std libs to library/mark-1247/+0
2020-07-23Rollup merge of #74141 - euclio:typos, r=steveklabnikManish Goregaokar-1/+1
libstd/libcore: fix various typos
2020-07-16Rollup merge of #73421 - janikrabe:master, r=joshtriplettManish Goregaokar-4/+7
Clarify effect of orphan rule changes on From/Into Updated documentation for `std::convert` and `std::convert::From` to reflect changes to orphan rule in Rust 1.41. It should no longer be necessary to implement `Into` directly, unless targeting an older version. r? @steveklabnik
2020-07-15Clarify effect of orphan rule changes on From/IntoJanik Rabe-4/+7
Updated documentation for `std::convert` and `std::convert::From` to reflect changes to orphan rule in Rust 1.41. It should no longer be necessary to implement Into directly, unless targeting an older version.
2020-07-09libstd/libcore: fix various typosAndy Russell-1/+1
2020-06-30Deny unsafe ops in unsafe fns, part 6LeSeulArtichaut-2/+0
And final part!!!
2020-06-30Deny unsafe ops in unsafe fns, part 1LeSeulArtichaut-1/+4
2020-06-25Auto merge of #72717 - poliorcetics:try-from-int-to-nzint, r=dtolnaybors-0/+39
Add TryFrom<{int}> for NonZero{int} Adds `TryFrom<{int}> for NonZero{int}`. It uses the existing `NonZero{int}::new()` and `Option::ok_or()` functions, meaning the checks are not repeated. I also added tests, I tried to follow the convention I saw in the test file. I also used `#[stable(feature = "nzint_try_from_int_conv", since = "1.46.0")]`, but I have no idea if the feature/version are correctly named or even correct.
2020-06-18Rollup merge of #73361 - estebank:non-primitive-cast, r=davidtwcoManish Goregaokar-0/+1
Tweak "non-primitive cast" error - Suggest borrowing expression if it would allow cast to work. - Suggest using `<Type>::from(<expr>)` when appropriate. - Minor tweak to `;` typo suggestion. Partily address #47136.
2020-06-15Tweak "non-primitive cast" errorEsteban Küber-0/+1
- Suggest borrowing expression if it would allow cast to work. - Suggest using `<Type>::from(<expr>)` when appropriate. - Minor tweak to `;` typo suggestion. Partily address #47136.
2020-06-10Migrate to numeric associated constsLzu Tao-3/+3
2020-06-08Added implementations for NonZero(U|I)sizeAlexis Bourget-0/+2
2020-05-29Added implementations for TryFrom<{int}> for NonZero{int}Alexis Bourget-0/+37
2020-04-25Bump bootstrap compilerMark Rousskov-8/+1
2020-04-03Rollup merge of #70487 - Mark-Simulacrum:float-unchecked-casts, r=SimonSapinMazdak Farrokhzad-4/+11
Stabilize float::to_int_unchecked This renames and stabilizes unsafe floating point to integer casts, which are intended to be the substitute for the currently unsound `as` behavior, once that changes to safe-but-slower saturating casts. As such, I believe this also likely unblocks #10184 (our oldest I-unsound issue!), as once this rolls out to stable it would be far easier IMO to change the behavior of `as` to be safe by default. This does not stabilize the trait or the associated method, as they are deemed internal implementation details (and consumers should not, generally, want to expose them, as in practice all callers likely know statically/without generics what the return type is). Closes #67058
2020-03-29Stabilize float::to_int_uncheckedMark Rousskov-4/+11
This renames and stabilizes unsafe floating point to integer casts, which are intended to be the substitute for the currently unsound `as` behavior, once that changes to safe-but-slower saturating casts.
2020-03-22Implement Hash for InfallibleKonrad Borowski-0/+8
2020-03-07Correct version that relaxed orphan rulesJonathan Giddy-1/+1
2020-01-06Use Self instead of $typeLzu Tao-14/+14
2019-12-18Propagate cfg bootstrapMark Rousskov-3/+1
2019-12-14Auto merge of #67224 - nikomatsakis:revert-stabilization-of-never-type, ↵bors-7/+88
r=centril Revert stabilization of never type Fixes https://github.com/rust-lang/rust/issues/66757 I decided to keep the separate `never-type-fallback` feature gate, but tried to otherwise revert https://github.com/rust-lang/rust/pull/65355. Seemed pretty clean. ( cc @Centril, author of #65355, you may want to check this over briefly )
2019-12-14Revert "Redefine `core::convert::Infallible` as `!`."Niko Matsakis-7/+88
This reverts commit 089229a1935fa9795cfdefa518c8f8c3beb66db8.
2019-12-14Auto merge of #67136 - oli-obk:const_stability, r=Centrilbors-0/+1
Require stable/unstable annotations for the constness of all stable fns with a const modifier r? @RalfJung @Centril Every `#[stable]` const fn now needs either a `#[rustc_const_unstable]` attribute or a `#[rustc_const_stable]` attribute. You can't silently stabilize the constness of a function anymore.
2019-12-13docs: std::convert::From: Fix typoShaleen Jain-1/+1
Fix a minor typo
2019-12-13Require stable/unstable annotations for the constness of all stable ↵Oliver Scherer-0/+1
functions with a `const` modifier
2019-12-08move from non zero impls to `libcore/convert/num.rs`Peter-0/+1115
2019-12-08leave a FIXMEMazdak Farrokhzad-1/+1
2019-12-08use `#[allow(unused_attributes)]` to paper over incr.comp problemMazdak Farrokhzad-0/+1
2019-12-06Move numeric `From` and `TryFrom` impls to `libcore/convert/num.rs`Simon Sapin-0/+331
This makes `libcore/num/mod.rs` slightly smaller. It’s still 4911 lines and not easy to navigate. This doesn’t change any public API.
2019-12-06Add `{f32,f64}::approx_unchecked_to<Int>` unsafe methodsSimon Sapin-0/+43
As discussed in https://github.com/rust-lang/rust/issues/10184 Currently, casting a floating point number to an integer with `as` is Undefined Behavior if the value is out of range. `-Z saturating-float-casts` fixes this soundness hole by making `as` “saturate” to the maximum or minimum value of the integer type (or zero for `NaN`), but has measurable negative performance impact in some benchmarks. There is some consensus in that thread for enabling saturation by default anyway, but provide an `unsafe fn` alternative for users who know through some other mean that their values are in range.
2019-12-06Make `core::convert` a directory-module with `mod.rs`Simon Sapin-0/+660