about summary refs log tree commit diff
path: root/src/libcore/slice
AgeCommit message (Collapse)AuthorLines
2020-07-27mv std libs to library/mark-7640/+0
2020-07-25Auto merge of #74510 - LukasKalbertodt:fix-range-from-index-panic, ↵bors-6/+19
r=hanna-kruppe Fix panic message when `RangeFrom` index is out of bounds Before, the `Range` method was called with `end = slice.len()`. Unfortunately, because `Range::index` first checks the order of the indices (start has to be smaller than end), an out of bounds index leads to `core::slice::slice_index_order_fail` being called. This prints the message 'slice index starts at 27 but ends at 10', which is worse than 'index 27 out of range for slice of length 10'. This is not only useful to normal users reading panic messages, but also for people inspecting assembly and being confused by `slice_index_order_fail` calls. You can see the produced assembly [here](https://rust.godbolt.org/z/GzMGWf) and try on Playground [here](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=aada5996b2f3848075a6d02cf4055743). (By the way. this is only about which panic function is called; I'm pretty sure it does not improve anything about performance).
2020-07-20Auto merge of #74010 - pierwill:pierwill-o-notation, r=GuillaumeGomezbors-11/+11
Use italics for O notation In documentation, I think it makes sense to italicize O notation (*O(n)*) as opposed to using back-ticks (`O(n)`). Visually, back-ticks focus the reader on the literal characters being used, making them ideal for representing code. Using italics, as far I can tell, more closely follows typographic conventions in mathematics and computer science. Just a suggestion, of course! 😇
2020-07-19Use italics for O notationpierwill-11/+11
Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
2020-07-20Slightly improve panic messages when range indices are out of boundsLukas Kalbertodt-6/+13
2020-07-19Fix panic message when `RangeFrom` index is out of boundsLukas Kalbertodt-2/+8
Before, the `Range` method was called with `end = slice.len()`. Unfortunately, because `Range::index` first checks the order of the indices (start has to be smaller than end), an out of bounds index leads to `core::slice::slice_index_order_fail` being called. This prints the message 'slice index starts at 27 but ends at 10', which is worse than 'index 27 out of range for slice of length 10'. This is not only useful to normal users reading panic messages, but also for people inspecting assembly and being confused by `slice_index_order_fail` calls.
2020-07-17Fix `Safety` docs for `from_raw_parts_mut`aticu-1/+1
2020-07-16apply bootstrap cfgsMark Rousskov-12/+0
2020-07-14Rollup merge of #73986 - RalfJung:raw-slice-as-ptr, r=sfacklerManish Goregaokar-52/+59
add (unchecked) indexing methods to raw (and NonNull) slices This complements the existing (unstable) `len` method. Unfortunately, for non-null slices, we cannot call this method `as_ptr` as that overlaps with the existing method of the same name. If this looks reasonable to accept, I propose to reuse the https://github.com/rust-lang/rust/issues/71146 tracking issue and rename the feature get to `slice_ptr_methods` or so. Cc @SimonSapin Fixes https://github.com/rust-lang/rust/issues/60639
2020-07-05Optimize is_ascii for &str and &[u8]Thom Chiovoloni-1/+101
2020-07-05make unchecked slice indexing helper methods use raw pointersRalf Jung-52/+59
2020-07-02Rollup merge of #73622 - LeSeulArtichaut:unsafe-libcore, r=nikomatsakisManish Goregaokar-61/+128
Deny unsafe ops in unsafe fns in libcore After `liballoc`, It's time for `libcore` :D I planned to do this bit by bit to avoid having a big chunk of diffs, so to make reviews easier, and to make the unsafe blocks narrower and take the time to document them properly. r? @nikomatsakis cc @RalfJung
2020-07-01Implement slice_strip featureLzu Tao-0/+62
2020-06-30Deny unsafe ops in unsafe fns, part 6LeSeulArtichaut-1/+0
And final part!!!
2020-06-30Deny unsafe ops in unsafe fns, part 5LeSeulArtichaut-45/+101
2020-06-30Deny unsafe ops in unsafe fns, part 4LeSeulArtichaut-18/+30
2020-06-28Rollup merge of #73577 - VillSnow:master, r=AmanieuManish Goregaokar-0/+54
Add partition_point Add partition_point in C++. Although existing binary_search in rust does not suitable when the slice has multiple hits, this function returns exact point of partition. The definition of this function is very clear and able to accept general matter, therefore you can easily get index which you want like lower/upper_bound. https://github.com/rust-lang/rfcs/issues/2184
2020-06-28Update src/libcore/slice/mod.rsVillSnow-1/+1
Co-authored-by: Amanieu d'Antras <amanieu@gmail.com>
2020-06-28Update tracking issue numberVillSnow-1/+1
2020-06-28Update doc commentVillSnow-6/+10
2020-06-28Merge branch 'master' of https://github.com/VillSnow/rustVillSnow-1/+2
2020-06-28Update src/libcore/slice/mod.rsVillSnow-1/+2
Co-authored-by: Lukas Kalbertodt <lukas.kalbertodt@gmail.com>
2020-06-28Add comment on use of unsafeVillSnow-0/+9
2020-06-24Fix links in `SliceIndex` documentationLeSeulArtichaut-0/+2
2020-06-23Rollup merge of #73398 - oli-obk:const_raw_ptr_cmp, r=varkor,RalfJung,nagisaManish Goregaokar-0/+17
A way forward for pointer equality in const eval r? @varkor on the first commit and @RalfJung on the second commit cc #53020
2020-06-22update: doc commentVillSnow-1/+3
2020-06-21fix: doc testVillSnow-3/+3
2020-06-21Add partition_pointVillSnow-0/+38
2020-06-20Address review commentsOliver Scherer-38/+9
2020-06-19Add fuzzy pointer comparison intrinsicsOliver Scherer-2/+48
2020-06-16Added some more documentations to unsafety blocks in slice/sort.rsHanif Bin Ariffin-11/+39
2020-06-13Added some unsafety documentation to partition_equalHanif Bin Ariffin-4/+8
2020-06-13Added unsafety documentation with partition and partition equalHanif Bin Ariffin-2/+7
These are simply indexing safety.
2020-06-13Document unsafety in partial_insertion_sortHanif Bin Ariffin-0/+2
We already implicitly (or explicitly??) do the bound checking for the indexing.
2020-06-13Added unsafety documentation to shift_tailHanif Bin Ariffin-0/+14
This is just the reverse of shift_head.
2020-06-13Added unsafety documentation to shift_headHanif Bin Ariffin-1/+15
2020-06-12Rollup merge of #72906 - lzutao:migrate-numeric-assoc-consts, r=dtolnayDylan DPC-8/+4
Migrate to numeric associated consts The deprecation PR is #72885 cc #68490 cc rust-lang/rfcs#2700
2020-06-10Migrate to numeric associated constsLzu Tao-8/+4
2020-06-08Fix the typo (size of the size)Stanislav Tkach-2/+2
2020-05-31Clarify terms in doc commentsJOE1994-2/+2
Doc comments of 'copy_from_slice' say that people should use 'clone_from_slice' when 'src' doesn't implement 'Copy'. However, 'src' is a reference and it always implements 'Copy'. The term 'src' should be fixed to 'T' in the doc comments. Thank you for reviewing this PR :)
2020-05-24Use sort_unstable_by in its own docsKagami Sascha Rosylight-1/+1
2020-05-21TypoRalf Jung-1/+1
2020-05-21Improve documentation of `slice::from_raw_parts`Daniel Henry-Mantilla-1/+30
This is to provide a more explicit statement against a code pattern that many people end up coming with, since the reason of it being unsound comes from the badly known single-allocation validity rule. Providing that very pattern as a counter-example could help mitigate that. Co-authored-by: Ralf Jung <post@ralfj.de>
2020-05-20split_inclusive: add tracking issue number (72360)Pyry Kontio-13/+13
2020-05-13Use simpler impls for some `Iterator` methods for slices.Nicholas Nethercote-17/+105
The default implementations of several `Iterator` methods use `fold` or `try_fold`, which works, but is overkill for slices and bloats the amount of LLVM IR generated and consequently hurts compile times. This commit adds the simple, obvious implementations for `for_each`, `all`, `any`, `find`, `find_map`, and simplifies the existing implementations for `position` and `rposition`. These changes reduce compile times significantly on some benchmarks.
2020-05-02slice::fill: take T by value.Bastian Kauschke-6/+7
2020-04-25Bump bootstrap compilerMark Rousskov-2/+2
2020-04-20Stop accessing module level int consts via crate::<Ty>Linus Färnstrand-2/+1
2020-04-15big-O notation: parenthesis, multiplication and backticksRalf Jung-7/+7
2020-04-14Tighten time complexity on the docmi_sawa-1/+1