about summary refs log tree commit diff
path: root/src/libcore/char/methods.rs
AgeCommit message (Collapse)AuthorLines
2020-07-27mv std libs to library/mark-1687/+0
2020-07-27Rollup merge of #73858 - tspiteri:const-methods, r=oli-obkManish Goregaokar-10/+10
Make more primitive integer methods const Now that #72437 has been merged and `const_if_match` is stable, these methods can be stabilized const. The methods are grouped in commits according to feature names: * `const_nonzero_int_methods` - `NonZero*::new` * some `const_checked_int_methods` - `{i*,u*}::checked_add` - `{i*,u*}::checked_sub` - `{i*,u*}::checked_mul` - `{i*,u*}::checked_neg` - `{i*,u*}::checked_shl` - `{i*,u*}::checked_shr` - `i*::checked_abs` * `const_saturating_int_methods` - `{i*,u*}::saturating_add` - `{i*,u*}::saturating_sub` - `{i*,u*}::saturating_mul` - `i*::saturating_neg` - `i*::saturating_abs` * `const_int_sign` - `i*::signum` * `const_ascii_ctype_on_intrinsics` - `{char,u8}::is_ascii_alphabetic` - `{char,u8}::is_ascii_uppercase` - `{char,u8}::is_ascii_lowercase` - `{char,u8}::is_ascii_alphanumeric` - `{char,u8}::is_ascii_digit` - `{char,u8}::is_ascii_hexdigit` - `{char,u8}::is_ascii_punctuation` - `{char,u8}::is_ascii_graphic` - `{char,u8}::is_ascii_whitespace` - `{char,u8}::is_ascii_control`
2020-07-22mark methods as constant since 1.47.0 instead of 1.46.0Trevor Spiteri-20/+10
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-29stabilize const_ascii_ctype_on_intrinsicsTrevor Spiteri-10/+20
2020-06-13Adjusted some doctests in libcore to use `should_panic`.Jake Degen-45/+17
Previously, some doctests were spawning new threads and joining them to indicate that a particular call should panic; this hurt readability, so the tests have been adjusted to simply call the method and use the `should_panic` marker.
2020-05-30encode_utf8_raw is not always valid UTF-8; clarify commentsRalf Jung-7/+12
2020-05-30also expose and use encode_utf16_raw for wtf8Ralf Jung-22/+37
2020-05-30expose char::encode_utf8_raw for libstdRalf Jung-40/+59
2020-05-21Rollup merge of #72371 - Elrendio:char_documentation, r=steveklabnikRalf Jung-2/+4
FIX - Char documentation for unexperienced users This is my first PR on rust and even if I've read [CONTRIBUTING.md](https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#pull-requests) I'm ensure everything is perfect. Sorry if I didn't follow the exact procedure. **What it does:** - Add an example in the char documentation **Explanation** Unexperienced users might not know that punctuation is `Case_Ignorable` and not `Uppercase` and `Lowercase` which mean that when checking if a string is uppercase one might be tempted to write: ```rust my_string.chars().all(char::is_uppercase) ``` However this will return false for `"HELLO WORLD"` which is not intuitive. Since the function `is_case_ignorable` doesn't exists I believe the correct way to check is: ```rust !my_string.chars().any(char::is_lowercase) ``` The aim of this example is to prevent unexperienced users to make an error which punctuation chars.
2020-05-20FIX - Char documentation for unexperienced usersElrendio-2/+4
2020-05-03Try to fix doc links in new `char` methods.Eduardo Sánchez Muñoz-16/+13
2020-05-03Make `std::char` functions and constants associated to `char`.Eduardo Sánchez Muñoz-0/+240
2020-02-11Improve `char::is_ascii_*` codeAndrea Canciani-10/+40
These methods explicitly check if a char is in a specific ASCII range, therefore the `is_ascii()` check is not needed, but LLVM seems to be unable to remove it. WARNING: this change improves the performance on ASCII `char`s, but complex checks such as `is_ascii_punctuation` become slower on non-ASCII `char`s.
2020-02-08Make the ASCII ctype inherent methods constDylan MacKenzie-10/+20
2020-01-14Replace old tables with new unicode dataMark Rousskov-8/+8
2019-12-23Minimize unsafety in encode_utf8Mark Rousskov-30/+29
Use slice patterns to avoid having to skip bounds checking
2019-12-18Propagate cfg bootstrapMark Rousskov-4/+1
2019-12-13Require stable/unstable annotations for the constness of all stable ↵Oliver Scherer-0/+4
functions with a `const` modifier
2019-12-11Some small readability improvementsAndre Bogus-10/+5
2019-11-26Format libcore with rustfmtDavid Tolnay-15/+3
This commit applies rustfmt with default settings to files in src/libcore *that are not involved in any currently open PR* to minimize merge conflicts. The list of files involved in open PRs was determined by querying GitHub's GraphQL API with this script: https://gist.github.com/dtolnay/aa9c34993dc051a4f344d1b10e4487e8 With the list of files from the script in `outstanding_files`, the relevant commands were: $ find src/libcore -name '*.rs' | xargs rustfmt --edition=2018 $ rg libcore outstanding_files | xargs git checkout -- Repeating this process several months apart should get us coverage of most of the rest of libcore.
2019-11-06Have tidy ensure that we document all `unsafe` blocks in libcoreOliver Scherer-0/+2
2019-10-12Improve docs on some char boolean methodsBO41-63/+109
2019-09-04remove XID and Pattern_White_Space unicode tables from libcoreAleksey Kladov-23/+0
They are only used by rustc_lexer, and are not needed elsewhere. So we move the relevant definitions into rustc_lexer (while the actual unicode data comes from the unicode-xid crate) and make the rest of the compiler use it.
2019-08-14Handle cfg(bootstrap) throughoutMark Rousskov-12/+2
2019-07-25Fix inconsistent highlight blocks.Tomasz Różański-7/+7
2019-07-22add rustc_private as a proper language feature gateAleksey Kladov-7/+12
At the moment, `rustc_private` as a (library) feature exists by accident: `char::is_xid_start`, `char::is_xid_continue` methods in libcore define it.
2019-06-30fix the same typo in doctestlcolaholicl-2/+2
2019-06-30Fix a typolcolaholicl-1/+1
Fix a typo in `libcore/char/methods.rs`
2019-06-14Change `...` to `..=` where applicableAaron Kutch-17/+17
2019-04-18libcore => 2018Taiki Endo-4/+5
2019-02-12Auto merge of #58051 - SimonSapin:str_escape, r=alexcrichtonbors-3/+1
Stabilize str::escape_* methods with new return types… … that implement `Display` and `Iterator<Item=char>`, as proposed in FCP: https://github.com/rust-lang/rust/issues/27791#issuecomment-376864727
2019-02-12Make the prema-unstable char::escape_debug_ext method crate-privateSimon Sapin-3/+1
2019-02-10libs: doc commentsAlexander Regueiro-10/+10
2018-12-25Remove licensesMark Rousskov-10/+0
2018-11-14core/char: Add comment to `to_digit()`Tobias Bieniek-0/+3
2018-11-14core/char: Drop `radix == 10` special caseTobias Bieniek-8/+1
This seems to perform equally well
2018-11-13core/char: Speed up `to_digit()` for `radix <= 10`Tobias Bieniek-5/+20
### Before ``` # Run 1 test char::methods::bench_to_digit_radix_10 ... bench: 16,265 ns/iter (+/- 1,774) test char::methods::bench_to_digit_radix_16 ... bench: 13,938 ns/iter (+/- 2,479) test char::methods::bench_to_digit_radix_2 ... bench: 13,090 ns/iter (+/- 524) test char::methods::bench_to_digit_radix_36 ... bench: 14,236 ns/iter (+/- 1,949) # Run 2 test char::methods::bench_to_digit_radix_10 ... bench: 16,176 ns/iter (+/- 1,589) test char::methods::bench_to_digit_radix_16 ... bench: 13,896 ns/iter (+/- 3,140) test char::methods::bench_to_digit_radix_2 ... bench: 13,158 ns/iter (+/- 1,112) test char::methods::bench_to_digit_radix_36 ... bench: 14,206 ns/iter (+/- 1,312) # Run 3 test char::methods::bench_to_digit_radix_10 ... bench: 16,221 ns/iter (+/- 2,423) test char::methods::bench_to_digit_radix_16 ... bench: 14,361 ns/iter (+/- 3,926) test char::methods::bench_to_digit_radix_2 ... bench: 13,097 ns/iter (+/- 671) test char::methods::bench_to_digit_radix_36 ... bench: 14,388 ns/iter (+/- 1,068) ``` ### After ``` # Run 1 test char::methods::bench_to_digit_radix_10 ... bench: 11,521 ns/iter (+/- 552) test char::methods::bench_to_digit_radix_16 ... bench: 12,926 ns/iter (+/- 684) test char::methods::bench_to_digit_radix_2 ... bench: 11,266 ns/iter (+/- 1,085) test char::methods::bench_to_digit_radix_36 ... bench: 14,213 ns/iter (+/- 614) # Run 2 test char::methods::bench_to_digit_radix_10 ... bench: 11,424 ns/iter (+/- 1,042) test char::methods::bench_to_digit_radix_16 ... bench: 12,854 ns/iter (+/- 1,193) test char::methods::bench_to_digit_radix_2 ... bench: 11,193 ns/iter (+/- 716) test char::methods::bench_to_digit_radix_36 ... bench: 14,249 ns/iter (+/- 3,514) # Run 3 test char::methods::bench_to_digit_radix_10 ... bench: 11,469 ns/iter (+/- 685) test char::methods::bench_to_digit_radix_16 ... bench: 12,852 ns/iter (+/- 568) test char::methods::bench_to_digit_radix_2 ... bench: 11,275 ns/iter (+/- 1,356) test char::methods::bench_to_digit_radix_36 ... bench: 14,188 ns/iter (+/- 1,501) ```
2018-11-13core/char: Replace condition + `panic!()` with `assert!()`Tobias Bieniek-3/+1
2018-11-10constify parts of libcore.Mazdak Farrokhzad-1/+1
2018-08-05Correct invalid feature attributesvarkor-20/+0
2018-08-01Auto merge of #51609 - dscorbett:is_numeric, r=alexcrichtonbors-4/+4
Treat gc=No characters as numeric [`char::is_numeric`](https://doc.rust-lang.org/std/primitive.char.html#method.is_numeric) and [`char::is_alphanumeric`](https://doc.rust-lang.org/std/primitive.char.html#method.is_alphanumeric) are documented to be defined “in terms of the Unicode General Categories 'Nd', 'Nl', 'No'”, but unicode.py does not group 'No' with the other 'N' categories. These functions therefore currently return `false` for characters like ⟨¾⟩ and ⟨①⟩.
2018-06-26migrate codebase to `..=` inclusive range patternsZack M. Davis-9/+9
These were stabilized in March 2018's #47813, and are the Preferred Way to Do It going forward (q.v. #51043).
2018-06-17Treat gc=No characters as numericDavid Corbett-4/+4
2018-05-21Only escape extended grapheme characters in the first positionvarkor-12/+22
2018-05-21Use Grapheme_Extend instead of Mnvarkor-8/+8
2018-05-21Remove example in test for is_nonspacing_mark because it's currently privatevarkor-10/+0
2018-05-21Escape combining characters in escape_debugvarkor-2/+24
2018-04-12Move core::char::printable to core::unicode::printableSimon Sapin-1/+1