about summary refs log tree commit diff
path: root/src/libcore/ops
AgeCommit message (Collapse)AuthorLines
2019-06-06Rollup merge of #61376 - czipperz:bound-cloned, r=sfacklerMazdak Farrokhzad-0/+23
Add Bound::cloned() Suggested by #61356
2019-06-05Remove dereferenceChris Gregory-1/+1
Co-Authored-By: Steven Fackler <sfackler@gmail.com>
2019-06-05Take self by value (Self is Copy here)Chris Gregory-1/+1
2019-06-05Aggregation of drive-by cosmetic changes.Alexander Regueiro-1/+1
2019-06-01Enable feature bound_cloned for testsChris Gregory-0/+1
2019-05-31Make Bound::cloned publicChris Gregory-1/+1
2019-05-30Fix compilation errorsChris Gregory-2/+2
2019-05-30Add Bound::cloned()Chris Gregory-0/+22
2019-05-30Fix links in Deref documentationGuillaume Gomez-6/+6
2019-04-22Remove double trailing newlinesvarkor-1/+0
2019-04-19libcore: deny more...Mazdak Farrokhzad-6/+6
2019-04-18libcore => 2018Taiki Endo-5/+5
2019-04-09std::ops::Div examples: correct nominator to numeratorAnders Kaseorg-14/+14
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2019-04-04Rollup merge of #59596 - LukasKalbertodt:fix-range-fmt, r=KimundiMazdak Farrokhzad-5/+17
Forward formatter settings to bounds of `Range<T>` in `fmt::Debug` impl Before this change, formatter settings were lost when printing a `Range`. For example, printing a `Range<f32>` with `{:.2?}` would not apply the precision modifier when printing the floats. Now the `Debug` impls look a bit more verbose, but modifier are not lost. --- I assume the exact output of `Debug` impls in `std` cannot be relied on by users and thus can change, right?
2019-04-02Rollup merge of #59529 - DevQps:improve-rem-docs, r=cuviperMazdak Farrokhzad-0/+15
Added documentation on the remainder (Rem) operator for floating points. # Description As has been explained in #57738 the remainder operator on floating points is not clear. This PR requests adds some information on how the `Rem` / remainder operator on floating points works. Note also that this description is for both `Rem<f32> for f32` and `Rem<f64> for f64` implementations. Ps. I wasn't really sure on how to formulate things. So please suggest changes if you have better idea's! closes #57738
2019-04-01Improved the example with numbers that can be exactly represented as floats ↵Christian-2/+3
and added a comment with the solution.
2019-04-01Forward formatter settings to bounds of `Range<T>` in `fmt::Debug` implLukas Kalbertodt-5/+17
Before this change, formatter settings were lost when printing a `Range`. For example, printing a `Range<f32>` with `{:.2?}` would not apply the precision modifier when printing the floats. Now the `Debug` impls look a bit more verbose, but modifier are not lost.
2019-03-30Added an example that shows how the remainder function on floating point ↵Christian-1/+11
values is computed internally.
2019-03-29Added documentation on the remainder (Rem) operator for floating points.Christian-0/+4
2019-03-22Rollup merge of #59190 - greg-kargin:master, r=sanxiynMazdak Farrokhzad-50/+50
consistent naming for Rhs type parameter in libcore/ops Rename RHS type parameter occurrences RHS->Rhs to make it consistent throughout files and follow naming conventions.
2019-03-18Replaced self-reflective explicit types with clearer `Self` or `Self::…` ↵Vincent Esche-34/+34
in stdlib docs
2019-03-16Rollup merge of #59152 - smmalis37:range_contains, r=SimonSapinkennytm-30/+19
Stabilize Range*::contains. Closes https://github.com/rust-lang/rust/issues/32311. There's also a bit of rustfmt on range.rs thrown in for good measure (I forgot to turn off format-on-save in VSCode).
2019-03-15consistent naming for Rhs type parameter in libcore/opsGrigorii Kargin-50/+50
2019-03-12Stabilize Range*::contains.Steven Malis-30/+19
2019-03-11Fix RangeBounds documentation to include inclusive operationsChris Gregory-1/+1
2019-03-11Standardize `Range*` documentationChris Gregory-26/+42
This updates the final example in the documentation for the types `Range`, `RangeFrom`, `RangeFull`, `RangeInclusive`, `RangeTo`, `RangeToInclusive`.
2019-02-23Rollup merge of #58122 - matthieu-m:range_incl_perf, r=dtolnayMazdak Farrokhzad-0/+2
RangeInclusive internal iteration performance improvement. Specialize `Iterator::try_fold` and `DoubleEndedIterator::try_rfold` to improve code generation in all internal iteration scenarios. This changes brings the performance of internal iteration with `RangeInclusive` on par with the performance of iteration with `Range`: - Single conditional jump in hot loop, - Unrolling and vectorization, - And even Closed Form substitution. Unfortunately, it only applies to internal iteration. Despite various attempts at stream-lining the implementation of `next` and `next_back`, LLVM has stubbornly refused to optimize external iteration appropriately, leaving me with a choice between: - The current implementation, for which Closed Form substitution is performed, but which uses 2 conditional jumps in the hot loop when optimization fail. - An implementation using a `is_done` boolean, which uses 1 conditional jump in the hot loop when optimization fail, allowing unrolling and vectorization, but for which Closed Form substitution fails. In the absence of any conclusive evidence as to which usecase matters most, and with no assurance that the lack of Closed Form substitution is not indicative of other optimizations being foiled, there is no way to pick one implementation over the other, and thus I defer to the statu quo as far as `next` and `next_back` are concerned.
2019-02-12Auto merge of #58341 - alexreg:cosmetic-2-doc-comments, r=steveklabnikbors-6/+6
Cosmetic improvements to doc comments This has been factored out from https://github.com/rust-lang/rust/pull/58036 to only include changes to documentation comments (throughout the rustc codebase). r? @steveklabnik Once you're happy with this, maybe we could get it through with r=1, so it doesn't constantly get invalidated? (I'm not sure this will be an issue, but just in case...) Anyway, thanks for your advice so far!
2019-02-10libs: doc commentsAlexander Regueiro-4/+4
2019-02-10tests: doc commentsAlexander Regueiro-2/+2
2019-02-07Add #[must_use] message to Fn* traitsTaiki Endo-3/+3
2019-02-03RangeInclusive internal iteration performance improvement.Matthieu M-0/+2
Specialize Iterator::try_fold and DoubleEndedIterator::try_rfold to improve code generation in all internal iteration scenarios. This changes brings the performance of internal iteration with RangeInclusive on par with the performance of iteration with Range: - Single conditional jump in hot loop, - Unrolling and vectorization, - And even Closed Form substitution. Unfortunately, it only applies to internal iteration. Despite various attempts at stream-lining the implementation of next and next_back, LLVM has stubbornly refused to optimize external iteration appropriately, leaving me with a choice between: - The current implementation, for which Closed Form substitution is performed, but which uses 2 conditional jumps in the hot loop when optimization fail. - An implementation using a "is_done" boolean, which uses 1 conditional jump in the hot loop when optimization fail, allowing unrolling and vectorization, but for which Closed Form substitution fails. In the absence of any conclusive evidence as to which usecase matters most, and with no assurance that the lack of Closed Form substitution is not indicative of other optimizations being foiled, there is no way to pick one implementation over the other, and thus I defer to the statu quo as far as next and next_back are concerned.
2019-01-27Change generator trait to use pinningWim Looman-14/+23
2019-01-27Auto merge of #57765 - Mark-Simulacrum:bootstrap-bump, r=alexcrichtonbors-1/+1
Bump bootstrap compiler to 1.33 beta r? @alexcrichton or @pietroalbini cc @rust-lang/release
2019-01-27Auto merge of #57826 - danielhenrymantilla:master, r=Centrilbors-1/+1
Fixed Deref coercion explanation for DerefMut using shared references
2019-01-26Bump bootstrap compiler to 1.33 betaMark Rousskov-1/+1
2019-01-22Fixed Deref coercion explanation for DerefMut using shared referencesdanielhenrymantilla-1/+1
2019-01-19Make `str` indexing generic on `SliceIndex`.Alexis Hunt-15/+0
2019-01-18Rollup merge of #57350 - folex:master, r=estebankMazdak Farrokhzad-0/+30
Better error note on unimplemented Index trait for string fixes #56740 I've tried to compile suggestion from comments in the issue #56740, but unsure of it. So I'm open to advice :) Current output will be like this: ```rust error[E0277]: the type `str` cannot be indexed by `{integer}` --> $DIR/str-idx.rs:3:17 | LL | let c: u8 = s[4]; //~ ERROR the type `str` cannot be indexed by `{integer}` | ^^^^ `str` cannot be indexed by `{integer}` | = help: the trait `std::ops::Index<{integer}>` is not implemented for `str` = note: you can use `.chars().nth()` or `.bytes().nth()` see chapter in The Book <https://doc.rust-lang.org/book/ch08-02-strings.html#indexing-into-strings> error: aborting due to previous error For more information about this error, try `rustc --explain E0277`. ``` `x.py test src/test/ui` succeeded and I've also tested output manually by compiling the following code: ```rust fn _f() { let s = std::string::String::from("hello"); let _c = s[0]; let s = std::string::String::from("hello"); let mut _c = s[0]; let s = "hello"; let _c = s[0]; let s = "hello"; let mut _c = &s[0]; } ``` Not sure if some docs should be changed too. I will also fix error message in the [Book :: Indexing into Strings](https://github.com/rust-lang/book/blob/db53e2e3cdf77beac853df6f29db4b3b86ea598c/src/ch08-02-strings.md#indexing-into-strings) if that PR will get approved :)
2019-01-05Show suggestion to use .char().nth() and link to The Book on unimplemented ↵folex-0/+30
Index trait
2019-01-01Fix broken links to second edition TRPL.Corey Farwell-6/+6
Fixes https://github.com/rust-lang/rust/issues/57104.
2018-12-25Remove licensesMark Rousskov-110/+0
2018-12-20Stabilize `Rc`, `Arc` and `Pin` as method receiversMichael Hewson-0/+19
This lets you write methods using `self: Rc<Self>`, `self: Arc<Self>`, `self: Pin<&mut Self>`, `self: Pin<Box<Self>`, and other combinations involving `Pin` and another stdlib receiver type, without needing the `arbitrary_self_types`. Other user-created receiver types can be used, but they still require the feature flag to use. This is implemented by introducing a new trait, `Receiver`, which the method receiver's type must implement if the `arbitrary_self_types` feature is not enabled. To keep composed receiver types such as `&Arc<Self>` unstable, the receiver type is also required to implement `Deref<Target=Self>` when the feature flag is not enabled. This lets you use `self: Rc<Self>` and `self: Arc<Self>` in stable Rust, which was not allowed previously. It was agreed that they would be stabilized in #55786. `self: Pin<&Self>` and other pinned receiver types do not require the `arbitrary_self_types` feature, but they cannot be used on stable because `Pin` still requires the `pin` feature.
2018-12-15Rollup merge of #56677 - aelred:must-use-on-traits, r=estebankPietro Albini-0/+3
#[must_use] on traits in stdlib Based on #55506. Adds `#[must_use]` attribute to traits in the stdlib: - `Iterator` - `Future` - `FnOnce` - `Fn` - `FnMut` There may be other traits that should have the attribute, but I couldn't find/think of any.
2018-12-12Bump to 1.33.0Alex Crichton-1/+1
* Update bootstrap compiler * Update version to 1.33.0 * Remove some `#[cfg(stage0)]` annotations Actually updating the version number is blocked on updating Cargo
2018-12-10Add #[must_use] attribute to stdlib traitsFelix Chapman-0/+3
2018-12-07Various minor/cosmetic improvements to codeAlexander Regueiro-4/+4
2018-11-10constify parts of libcore.Mazdak Farrokhzad-2/+2
2018-11-01update DispatchFromDyn doctestMichael Hewson-0/+3
2018-11-01Replace CoerceSized trait with DispatchFromDynMichael Hewson-26/+26
Rename `CoerceSized` to `DispatchFromDyn`, and reverse the direction so that, for example, you write ``` impl<T: Unsize<U>, U> DispatchFromDyn<*const U> for *const T {} ``` instead of ``` impl<T: Unsize<U>, U> DispatchFromDyn<*const T> for *const U {} ``` this way the trait is really just a subset of `CoerceUnsized`. The checks in object_safety.rs are updated for the new trait, and some documentation and method names in there are updated for the new trait name — e.g. `receiver_is_coercible` is now called `receiver_is_dispatchable`. Since the trait now works in the opposite direction, some code had to updated here for that too. I did not update the error messages for invalid `CoerceSized` (now `DispatchFromDyn`) implementations, except to find/replace `CoerceSized` with `DispatchFromDyn`. Will ask for suggestions in the PR thread.