about summary refs log tree commit diff
path: root/src/libcore
AgeCommit message (Collapse)AuthorLines
2017-04-05Rollup merge of #41028 - bluss:rev-rfind, r=alexcrichtonAriel Ben-Yehuda-1/+13
Let .rev()'s find use the underlying rfind and vice versa - Connect the plumbing in an obvious way from Rev's find → underlying rfind and vice versa - A style change in the provided implementation for Iterator::rfind, using simple next_back when it is enough
2017-04-05Rollup merge of #40943 - Amanieu:offset_to, r=alexcrichtonAriel Ben-Yehuda-3/+80
Add ptr::offset_to This PR adds a method to calculate the signed distance (in number of elements) between two pointers. The resulting value can then be passed to `offset` to get one pointer from the other. This is similar to pointer subtraction in C/C++. There are 2 special cases: - If the distance is not a multiple of the element size then the result is rounded towards zero. (in C/C++ this is UB) - ZST return `None`, while normal types return `Some(isize)`. This forces the user to handle the ZST case in unsafe code. (C/C++ doesn't have ZSTs)
2017-04-05Rollup merge of #40927 - stjepang:docs-atomic-overflow-note, r=alexcrichtonAriel Ben-Yehuda-10/+29
Add a note about overflow for fetch_add/fetch_sub Fixes #40916 Fixes #34618 r? @steveklabnik
2017-04-05Rollup merge of #40709 - lifthrasiir:leaner-unicode-debug-str, r=alexcrichtonAriel Ben-Yehuda-771/+467
Reduce a table used for `Debug` impl of `str`. This commit shrinks the size of the aforementioned table from 2,102 bytes to 1,197 bytes. This is achieved by an observation that most `u16` entries are common in its upper byte. Specifically: - `SINGLETONS` now uses two tables, one for (upper byte, lower count) and another for a series of lower bytes. For each upper byte given number of lower bytes are read and compared. - `NORMAL` now uses a variable length format for the count of "true" codepoints and "false" codepoints (one byte with MSB unset, or two big-endian bytes with the first MSB set). The code size and relative performance roughly remains same as this commit tries to optimize for both. The new table and algorithm has been verified for the equivalence to older ones. In my x86-64 macOS laptop with `rustc 1.17.0-nightly (0aeb9c129 2017-03-15)`, `-C opt-level=3 -C lto` gives the following: * The old routine compiles to 2,102 bytes of data and 416 bytes of code. * The new routine compiles to 1,197 bytes of data and 448 bytes of code. Counting a number of all printable Unicode scalar values (128,003, if you wonder) by filtering `0..0x110000` with `std::char::from_u32` and `is_printable` took 50±7ms for both. This can be surprising as the new routine *has* to do more calculations; this is partly explained by the fact that a linear search of `SINGLETONS` has been replaced by *two* linear searches for upper and lower bytes, which greatly reduces the iteration count.
2017-04-05Add safe wrapper for atomic_singlethreadfence_*Jon Gjengset-0/+41
2017-04-05Rollup merge of #41066 - steveklabnik:fix-links, r=frewsxcvCorey Farwell-36/+54
Fix links part of https://github.com/rust-lang/rust/issues/40912 []\n() is not actually a link. r? @frewsxcv @GuillaumeGomez
2017-04-05Rollup merge of #41043 - GuillaumeGomez:sup_balise, r=steveklabnikCorey Farwell-9/+10
Replace ^ with <sup> html balise r? @steveklabnik
2017-04-05Rollup merge of #40999 - irfanhudda:improve-option-docs, r=steveklabnikCorey Farwell-3/+21
Improve option API docs Associated Issue: #29366 Improve `option` API docs for * `IntoIter` struct * `Iter` struct * `IterMut` struct r? @steveklabnik
2017-04-05Rollup merge of #40997 - donniebishop:from_utf8_linking, r=steveklabnikCorey Farwell-8/+15
Added links to types in from_utf8 description References #29375. Link to types mentioned in the documentation for `from_utf8` (`str`, `&[u8`], etc). Paragraphs were reformatted to keep any one line from being excessively long, but are otherwise unchanged.
2017-04-05Rollup merge of #40992 - donniebishop:utf8err_linking, r=alexcrichtonCorey Farwell-3/+8
Added links to from_utf8 methods in Utf8Error Referencing #29375. Linked the `from_utf8` methods for both `String` and `str` in the description. Also linked the `u8` to its documentation
2017-04-05Reduce a table used for `Debug` impl of `str`.Kang Seonghoon-771/+467
This commit shrinks the size of the aforementioned table from 2,102 bytes to 1,197 bytes. This is achieved by an observation that most u16 entries are common in its upper byte. Specifically: - SINGLETONS now uses two tables, one for (upper byte, lower count) and another for a series of lower bytes. For each upper byte given number of lower bytes are read and compared. - NORMAL now uses a variable length format for the count of "true" codepoints and "false" codepoints (one byte with MSB unset, or two big-endian bytes with the first MSB set). The code size and relative performance roughly remains same as this commit tries to optimize for both. The new table and algorithm has been verified for the equivalence to older ones.
2017-04-05tidy clean and small text fixsteveklabnik-18/+18
2017-04-05Add tracking issue for offset_toAmanieu d'Antras-2/+2
2017-04-04Fix linkssteveklabnik-36/+54
part of https://github.com/rust-lang/rust/issues/40912 []\n() is not actually a link.
2017-04-04simplify implementation of [T]::splitn and friends #41020Jason Orendorff-17/+9
2017-04-04add [T]::rsplit() and rsplit_mut() #41020Jason Orendorff-0/+139
2017-04-04AsMut exampleDylan Maccora-7/+15
2017-04-03Replace ^ with <sup> html baliseGuillaume Gomez-9/+10
2017-04-03Move libXtest into libX/testsStjepan Glavina-6/+7667
This change moves: 1. `libcoretest` into `libcore/tests` 2. `libcollectionstest` into `libcollections/tests` This is a follow-up to #39561.
2017-04-03Wrapped to 80 characters. Fix links.Dylan Maccora-40/+58
2017-04-03Add ptr::offset_toAmanieu d'Antras-3/+80
2017-04-03iter: Simplification in rfind's provided implementationUlrik Sverdrup-1/+1
- Prefer simpler constructs instead of going through &mut I's Iterator implementation.
2017-04-03iter: Use underlying find/rfind for the same methods in RevUlrik Sverdrup-0/+12
2017-04-02Minor changes to core::option docsIrfan Hudda-6/+6
2017-04-01Improve docs of core::option::IterIrfan Hudda-1/+7
2017-04-01Improve docs of core::option::IterMutIrfan Hudda-1/+7
2017-04-01Improve docs of core::option::IntoIterIrfan Hudda-1/+7
2017-04-01Added links to types in from_utf8 descriptionDonnie Bishop-8/+15
2017-04-01Convert docs clean up.Dylan Maccora-31/+114
2017-03-31Added links to from_utf8 methods in Utf8ErrorDonnie Bishop-3/+8
2017-03-31Rollup merge of #40935 - donniebishop:str_boilerplate_docs, r=steveklabnikCorey Farwell-7/+24
Modify str Structs descriptions References #29375. Modified descriptions of multiple structs to be more in line with structs found under [`std::iter`](https://doc.rust-lang.org/std/iter/#structs), such as [`Chain`](https://doc.rust-lang.org/std/iter/struct.Chain.html) and [`Enumerate`](https://doc.rust-lang.org/std/iter/struct.Enumerate.html)
2017-03-31Rollup merge of #40871 - projektir:atomic_links, r=steveklabnikCorey Farwell-17/+49
Adding links for Atomics docs #29377 r? @steveklabnik This should be good for `std::sync::atomic`. The other pages still need more (examples, etc.).
2017-03-31Rollup merge of #40934 - SamWhited:improve_write_writeln_docs, r=steveklabnikCorey Farwell-38/+16
Improve the docs for the write and writeln macros This change reduces duplication by linking the documentation for `writeln!` to `write!`. It also restructures the `write!` documentation to read in a more logical manner (I hope; feedback would be welcome). Updates #29329, #29381
2017-03-31Rollup merge of #40929 - bluss:full-reverse, r=alexcrichtonCorey Farwell-0/+9
Implement all PartialOrd methods for Reverse When making a forwarding wrapper we must in general forward all methods, so that we use the type's own `lt` for example instead of the default. Example important case: f32's partial_cmp does several operations but its lt is a primitive. Follow up on #40720
2017-03-31Auto merge of #40737 - nagisa:safe-slicing-strs, r=BurntSushibors-51/+327
Checked slicing for strings cc https://github.com/rust-lang/rust/issues/39932
2017-03-30Remove parentheses in method referencesDonnie Bishop-8/+8
2017-03-30Modify Chars' descriptionDonnie Bishop-3/+7
2017-03-30Modify CharIndices' descriptionDonnie Bishop-1/+9
2017-03-30Improve the docs for the write and writeln macrosSam Whited-38/+16
This change reduces duplication by linking the documentation for `writeln!` to `write!`. It also restructures the `write!` documentation to read in a more logical manner. Updates #29329, #29381
2017-03-30Modify Bytes' descriptionDonnie Bishop-4/+5
2017-03-30Modify Lines' descriptionDonnie Bishop-2/+6
2017-03-30cmp: Implement all PartialOrd methods for ReverseUlrik Sverdrup-0/+9
When making a forwarding wrapper we must in general forward all methods, so that we use the type's own `lt` for example instead of the default. Example important case: f32's partial_cmp does several operations but its lt is a primitive.
2017-03-30More consistent wordingStjepan Glavina-10/+25
2017-03-30Add a note about overflow for fetch_add/fetch_subStjepan Glavina-0/+4
2017-03-29Rollup merge of #40907 - donniebishop:utf8_unchecked_docs, r=steveklabnikCorey Farwell-1/+3
Linked str in from_utf_unchecked References #29375. Linked `str` in from_utf_unchecked's documentation to the docs for primitive `str`
2017-03-29Rollup merge of #40832 - pftbest:fix_msp430, r=stjepangCorey Farwell-1/+3
libcore: fix compilation on 16bit target (MSP430). Since PR #40601 has been merged, libcore no longer compiles on MSP430. The reason is this code in `break_patterns`: ```rust let mut random = len; random ^= random << 13; random ^= random >> 17; random ^= random << 5; random &= modulus - 1; ``` It assumes that `len` is at least a 32 bit integer. As a workaround replace `break_patterns` with an empty function for 16bit targets. cc @stjepang cc @alexcrichton
2017-03-29Linked str in from_utf_uncheckedDonnie Bishop-1/+3
2017-03-29Rollup merge of #40897 - irfanhudda:fix-typo-char, r=BurntSushiCorey Farwell-1/+1
Fix typo in libcore/char.rs
2017-03-29Rollup merge of #40720 - mitsuhiko:feature/rev-key, r=BurntSushiCorey Farwell-0/+35
Added core::cmp::Reverse for sort_by_key reverse sorting I'm not sure if this is the best way to go about proposing this feature but it's pretty useful. It allows you to use `sort_by_key` and return tuples where a single item is then reversed to how it normally sorts. I quite miss something like this in Rust currently though I'm not sure if this is the best way to implement it.
2017-03-29Fix typo in libcore/char.rsIrfan Hudda-1/+1