about summary refs log tree commit diff
path: root/src/liballoc
AgeCommit message (Collapse)AuthorLines
2017-11-05Auto merge of #44042 - LukasKalbertodt:ascii-methods-on-instrinsics, ↵bors-16/+490
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-04Rollup merge of #45681 - Ljzn:patch-1, r=kennytmkennytm-1/+1
Fix typo.
2017-11-03Mark several ascii methods as unstable againLukas Kalbertodt-20/+25
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-03Remove unused AsciiExt imports and fix tests related to ascii methodsLukas Kalbertodt-16/+0
Many AsciiExt imports have become useless thanks to the inherent ascii methods added in the last commits. These were removed. In some places, I fully specified the ascii method being called to enforce usage of the AsciiExt trait. Note that some imports are not removed but tagged with a `#[cfg(stage0)]` attribute. This is necessary, because certain ascii methods are not yet available in stage0. All those imports will be removed later. Additionally, failing tests were fixed. The test suite should exit successfully now.
2017-11-03Copy `AsciiExt` methods to `str` directlyLukas Kalbertodt-1/+277
This is done in order to deprecate AsciiExt eventually. Note that this commit contains a bunch of `cfg(stage0)` statements. This is due to a new compiler feature this commit depends on: the `slice_u8` lang item. Once this lang item is available in the stage0 compiler, all those cfg flags (and more) can be removed.
2017-11-03Copy `AsciiExt` methods to `[u8]` directlyLukas Kalbertodt-0/+209
This is done in order to deprecate AsciiExt eventually. Note that this commit contains a bunch of `cfg(stage0)` statements. This is due to a new compiler feature I am using: the `slice_u8` lang item. Once this lang item is available in the stage0 compiler, all those cfg flags (and more) can be removed.
2017-11-02Auto merge of #45306 - whitequark:ref_slice, r=alexcrichtonbors-0/+3
Bring back slice::ref_slice as slice::from_ref. These functions were deprecated and removed in 1.5, but such simple functionality shouldn't require using unsafe code, and it isn't cluttering libstd too much. The original removal was quite contentious (see #27774), since then we've had precedent for including such nuggets of functionality (see rust-lang/rfcs#1789), and @nikomatsakis has provided a lot of use cases in https://github.com/rust-lang/rfcs/pull/1789#issuecomment-314640034. Hence this PR. I'm not too sure what to do with stability, feel free to correct me. It seems pointless to go through stabilization for these functions though. cc @aturon
2017-11-01De-stabilize core::slice::{from_ref, from_ref_mut}.whitequark-1/+2
2017-11-01Fix typo.Lance John-1/+1
2017-10-23Bring back slice::ref_slice as slice::from_ref.whitequark-0/+2
These functions were deprecated and removed in 1.5, but such simple functionality shouldn't require using unsafe code, and it isn't cluttering libstd too much.
2017-10-20Fix most rendering warnings from switching to CommonMarksteveklabnik-4/+3
2017-10-17added non trivial examples of closures for str::findChristian Poveda-2/+2
2017-10-17added examples of closuresChristian Poveda-1/+3
2017-10-13Rollup merge of #45133 - GuillaumeGomez:usize-index-msg, r=dtolnaykennytm-1/+25
usize index message for vec
2017-10-10Auto merge of #44877 - nvzqz:box-conversions, r=alexcrichtonbors-4/+40
Improve raw Box conversions This PR has two goals: - Reduce use of `mem::transmute` in `Box` conversions I understand that `mem::transmute`-ing non `#[repr(C)]` types is implementation-defined behavior. This may not matter within the reference implementation of Rust, but I believe it's important to remain consistent. For example, I noticed that `str::from_utf8_unchecked` went from using `mem::transmute` to using pointer casts. - Make `Box` pointer conversions more straightforward regarding `Unique`
2017-10-09usize index message for vecGuillaume Gomez-1/+25
2017-10-08Rollup merge of #45052 - steveklabnik:gh44105, r=dtolnaykennytm-3/+5
Modify Rc/Arc language around mutability There are a few exceptions to the rule that Arc/Rc are immutable. Rather than dig into the details, add "generally" to hint at this difference, as it's kind of a distraction at this point in the docs. Additionally, Arc's docs were slightly different here generally, so add in both the existing language and the exception. Fixes #44105
2017-10-06Add unique feature in Box::from_unique docsNikolai Vazquez-3/+7
2017-10-06Add missing word in Box::from_unique docsNikolai Vazquez-2/+2
2017-10-06Create Box::from_unique functionNikolai Vazquez-3/+35
Provides a reasonable interface for Box::from_raw implementation. Does not get around the requirement of mem::transmute for converting back and forth between Unique and Box.
2017-10-06Revert to using mem::transmute in Box::from_rawNikolai Vazquez-1/+1
Same reasons as commit 904133e1e28b690e2bbd101b719509aa897539a0.
2017-10-06Revert to using mem::transmute in Box::into_uniqueNikolai Vazquez-3/+1
Seems to cause this error: "Cannot handle boxed::Box<[u8]> represented as TyLayout".
2017-10-06Auto merge of #44734 - mchlrhw:wip/hashmap-entry-and-then, r=BurntSushibors-0/+34
Implement `and_modify` on `Entry` ## Motivation `Entry`s are useful for allowing access to existing values in a map while also allowing default values to be inserted for absent keys. The existing API is similar to that of `Option`, where `or` and `or_with` can be used if the option variant is `None`. The `Entry` API is, however, missing an equivalent of `Option`'s `and_then` method. If it were present it would be possible to modify an existing entry before calling `or_insert` without resorting to matching on the entry variant. Tracking issue: https://github.com/rust-lang/rust/issues/44733.
2017-10-06Implement `entry_and_modify`mchlrhw-0/+34
2017-10-05Modify Rc/Arc language around mutabilitysteveklabnik-3/+5
There are a few exceptions to the rule that Arc/Rc are immutable. Rather than dig into the details, add "generally" to hint at this difference, as it's kind of a distraction at this point in the docs. Additionally, Arc's docs were slightly different here generally, so add in both the existing language and the exception. Fixes #44105
2017-10-05Auto merge of #44943 - nivkner:fixme_fixup, r=dtolnaybors-3/+3
address some FIXME whose associated issues were marked as closed part of #44366
2017-10-04Auto merge of #44890 - nvzqz:str-box-transmute, r=alexcrichtonbors-8/+4
Remove mem::transmute used in Box<str> conversions Given that https://github.com/rust-lang/rust/pull/44877 is failing, I decided to make a separate PR. This is done with the same motivation: to avoid `mem::transmute`-ing non `#[repr(C)]` types.
2017-10-01Resolves #36284 - vec.rs documentationSean Prashad-5/+1
2017-09-30address some `FIXME`s whose associated issues were marked as closedNiv Kaminer-3/+3
remove FIXME(#13101) since `assert_receiver_is_total_eq` stays. remove FIXME(#19649) now that stability markers render. remove FIXME(#13642) now the benchmarks were moved. remove FIXME(#6220) now that floating points can be formatted. remove FIXME(#18248) and write tests for `Rc<str>` and `Rc<[u8]>` remove reference to irelevent issues in FIXME(#1697, #2178...) update FIXME(#5516) to point to getopts issue 7 update FIXME(#7771) to point to RFC 628 update FIXME(#19839) to point to issue 26925
2017-09-29Rollup merge of #44824 - dtolnay:22really21, r=alexcrichtonMark Simulacrum-6/+6
Backport libs stabilizations to 1.21 beta Includes the following stabilizations: - tcpstream_connect_timeout https://github.com/rust-lang/rust/pull/44563 - iterator_for_each https://github.com/rust-lang/rust/pull/44567 - ord_max_min https://github.com/rust-lang/rust/pull/44593 - compiler_fences https://github.com/rust-lang/rust/pull/44595 - needs_drop https://github.com/rust-lang/rust/pull/44639 - vec_splice https://github.com/rust-lang/rust/pull/44640 These have been backported in https://github.com/rust-lang/rust/pull/44823.
2017-09-27Remove mem::transmute used in Box<str> conversionsNikolai Vazquez-8/+4
2017-09-27Auto merge of #44709 - Badel2:inclusive-range-dotdoteq, r=petrochenkovbors-39/+39
Initial support for `..=` syntax #28237 This PR adds `..=` as a synonym for `...` in patterns and expressions. Since `...` in expressions was never stable, we now issue a warning. cc @durka r? @aturon
2017-09-26Remove uses of mem::transmute in Box methodsNikolai Vazquez-3/+5
Makes use of conversions via Unique.
2017-09-24Backport libs stabilizations to 1.21 betaDavid Tolnay-6/+6
This includes the following stabilizations: - tcpstream_connect_timeout https://github.com/rust-lang/rust/pull/44563 - iterator_for_each https://github.com/rust-lang/rust/pull/44567 - ord_max_min https://github.com/rust-lang/rust/pull/44593 - compiler_fences https://github.com/rust-lang/rust/pull/44595 - needs_drop https://github.com/rust-lang/rust/pull/44639 - vec_splice https://github.com/rust-lang/rust/pull/44640
2017-09-23Fix capacity comparison in reserveSteven Fackler-1/+1
You can otherwise end up in a situation where you don't actually resize but still call into handle_cap_increase which then corrupts head/tail. Closes #44800
2017-09-22Add support for `..=` syntaxAlex Burka-39/+39
Add ..= to the parser Add ..= to libproc_macro Add ..= to ICH Highlight ..= in rustdoc Update impl Debug for RangeInclusive to ..= Replace `...` to `..=` in range docs Make the dotdoteq warning point to the ... Add warning for ... in expressions Updated more tests to the ..= syntax Updated even more tests to the ..= syntax Updated the inclusive_range entry in unstable book
2017-09-22Add missing links for ArcGuillaume Gomez-5/+8
2017-09-21Auto merge of #44682 - bluss:iter-rfold, r=dtolnaybors-0/+17
Add iterator method .rfold(init, function); the reverse of fold rfold is the reverse version of fold. Fold allows iterators to implement a different (non-resumable) internal iteration when it is more efficient than the external iteration implemented through the next method. (Common examples are VecDeque and .chain()). Introduce rfold() so that the same customization is available for reverse iteration. This is achieved by both adding the method, and by having the Rev\<I> adaptor connect Rev::rfold → I::fold and Rev::fold → I::rfold. On the surface, rfold(..) is just .rev().fold(..), but the special case implementations allow a data structure specific fold to be used through for example .iter().rev(); we thus have gains even for users never calling exactly rfold themselves.
2017-09-20Auto merge of #44355 - Xaeroxe:optimize_drain_filter, r=alexcrichtonbors-1/+7
Optimize drain_filter This PR cuts out two copies from each iteration of `drain_filter` by exchanging the swap operation for a copy_nonoverlapping function call instead. Since the data being swapped is not needed anymore we can just overwrite it instead.
2017-09-18alloc: Implement rfold for VecDeque iteratorsUlrik Sverdrup-0/+17
2017-09-18Add requested commentJacob Kiesel-0/+3
2017-09-18Rollup merge of #44640 - budziq:stabilize_splice, r=dtolnayAlex Crichton-8/+7
Stabilized vec_splice and modified splice tracking issue This stabilizes the vec_splice (Vec part of splice RFC) Fixes #32310.
2017-09-17Rollup merge of #44073 - murarth:rc-into-raw-unsized, r=alexcrichtonTim Neumann-33/+71
Implement `Arc`/`Rc` raw pointer conversions for `?Sized` * Add `T: ?Sized` bound to {`Arc`,`Rc`}::{`from_raw`,`into_raw`}
2017-09-17Updated tracking issue for String::splice and its unstable-book entryMichal Budzynski-1/+1
2017-09-17stabilized vec_splice (fixes #32310)Michal Budzynski-7/+6
2017-09-16Rollup merge of #44273 - bluss:rc-downcast, r=alexcrichtonAlex Crichton-0/+61
Implement <Rc<Any>>::downcast * Implement `<Rc<Any>>::downcast::<T>` * New unstable method. Works just like Box\<Any\>, but for Rc. * Any has two cases for its methods: Any and Any + Send; Rc is never Send, so that case is skipped for Rc. * Motivation for being a method with self is to match Box and there is no user-supplied type; the inner type is Any and downcast does not conflict with any method of Any. * Arc was skipped because Any itself has no downcast for the case that makes most sense: Any + Send + Sync
2017-09-16Implement `Arc`/`Rc` raw pointer conversions for `?Sized`Murarth-33/+71
* Add `T: ?Sized` bound to {`Arc`,`Rc`}::{`from_raw`,`into_raw`}
2017-09-15alloc: Add tracking issue for rc_downcastUlrik Sverdrup-1/+1
2017-09-14Rollup merge of #44572 - frewsxcv:frewsxcv-from-utf16-lossy, r=QuietMisdreavusCorey Farwell-0/+7
Clarify return type of `String::from_utf16_lossy`. Fixes https://github.com/rust-lang/rust/issues/32874
2017-09-14Rollup merge of #44559 - frewsxcv:frewsxcv-rm-loop, r=sfacklerCorey Farwell-8/+6
Remove unneeded `loop`. None