about summary refs log tree commit diff
path: root/library/alloc/tests/str.rs
AgeCommit message (Collapse)AuthorLines
2025-03-07Move all alloc integration tests to a new alloctests cratebjorn3-2461/+0
2025-02-19Rollup merge of #120580 - HTGAzureX1212:HTGAzureX1212/issue-45795, r=m-ou-seMatthias Krüger-2/+3
Add `MAX_LEN_UTF8` and `MAX_LEN_UTF16` Constants This pull request adds the `MAX_LEN_UTF8` and `MAX_LEN_UTF16` constants as per #45795, gated behind the `char_max_len` feature. The constants are currently applied in the `alloc`, `core` and `std` libraries.
2025-02-16add MAX_LEN_UTF8 and MAX_LEN_UTF16 constantsHTGAzureX1212-2/+3
2025-02-08Rustfmtbjorn3-77/+88
2025-02-06Remove some unnecessary parens in `assert!` conditionsEsteban Küber-11/+11
While working on #122661, some of these started triggering our "unnecessary parens" lints due to a change in the `assert!` desugaring. A cursory search identified a few more. Some of these have been carried from before 1.0, were a bulk rename from the previous name of `assert!` left them in that state. I went and removed as many of these unnecessary parens as possible in order to have fewer annoyances in the future if we make the lint smarter.
2024-09-23Improve autovectorization of to_lowercase / to_uppercase functionsJörn Horstmann-0/+3
Refactor the code in the `convert_while_ascii` helper function to make it more suitable for auto-vectorization and also process the full ascii prefix of the string. The generic case conversion logic will only be invoked starting from the first non-ascii character. The runtime on microbenchmarks with ascii-only inputs improves between 1.5x for short and 4x for long inputs on x86_64 and aarch64. The new implementation also encapsulates all unsafe inside the `convert_while_ascii` function. Fixes #123712
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-88/+77
2024-07-29Reformat `use` declarations.Nicholas Nethercote-1/+2
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-15Remove generic lifetime parameter of trait `Pattern`Benoît du Garreau-8/+6
Use a GAT for `Searcher` associated type because this trait is always implemented for every lifetime anyway.
2024-05-08fix #124714 str.to_lowercase sigma handlingMarcondiro-0/+3
2023-11-27optimize str::iter::Chars::advance_byThe 8472-0/+11
this avoids part of the char decoding work by not looking at utf8 continuation bytes
2023-08-15Auto merge of #112387 - clarfonthey:non-panicking-ceil-char-boundary, r=m-ou-sebors-5/+2
Don't panic in ceil_char_boundary Implementing the alternative mentioned in this comment: https://github.com/rust-lang/rust/issues/93743#issuecomment-1579935853 Since `floor_char_boundary` will always work (rounding down to the length of the string is possible), it feels best for `ceil_char_boundary` to not panic either. However, the semantics of "rounding up" past the length of the string aren't very great, which is why the method originally panicked in these cases. Taking into account how people are using this method, it feels best to simply return the end of the string in these cases, so that the result is still a valid char boundary.
2023-07-20Fix size_hint for EncodeUtf16Andrew Tribick-0/+22
2023-07-12Flip cfg's for bootstrap bumpMark Rousskov-1/+1
2023-06-08Fix testltdk-5/+2
2023-05-27Allow newly uplifted invalid_from_utf8 lintUrgau-0/+2
2023-03-23Rollup merge of #100311 - xfix:lines-fix-handling-of-bare-cr, r=ChrisDentonDylan DPC-7/+19
Fix handling of trailing bare CR in str::lines Continuing from #91191. Fixes #94435.
2022-11-22add test for issue 104726The 8472-0/+12
2022-11-15generalize str.contains() tests to a range of haystack sizesThe 8472-5/+21
The Big-O is cubic, but this is only called with ~70 chars so it's still fast enough
2022-10-06Fix handling of trailing bare CR in str::linesKonrad Borowski-7/+19
Previously "bare\r" was split into ["bare"] even though the documentation said that only LF and CRLF count as newlines. This fix is a behavioural change, even though it brings the behaviour into line with the documentation, and into line with that of `std::io::BufRead::lines()`. This is an alternative to #91051, which proposes to document rather than fix the behaviour. Fixes #94435. Co-authored-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2022-08-21Replace most uses of `pointer::offset` with `add` and `sub`Maybe Waffle-5/+5
2022-05-26improve case conversion happy pathConrad Ludgate-0/+14
2022-03-31make utf8_char_counts test faster in MiriRalf Jung-4/+7
2022-03-27Debug print char 0 as '\0' rather than '\u{0}'David Tolnay-1/+1
2022-03-10Use implicit capture syntax in format_argsT-O-R-U-S-5/+5
This updates the standard library's documentation to use the new syntax. The documentation is worthwhile to update as it should be more idiomatic (particularly for features like this, which are nice for users to get acquainted with). The general codebase is likely more hassle than benefit to update: it'll hurt git blame, and generally updates can be done by folks updating the code if (and when) that makes things more readable with the new format. A few places in the compiler and library code are updated (mostly just due to already having been done when this commit was first authored).
2022-02-07Add {floor,ceil}_char_boundary methods to strltdk-0/+92
2022-02-05Ensure non-power-of-two sizes are tested in the Chars::count testThom Chiovoloni-2/+4
2022-02-05Optimize `core::str::Chars::count`Thom Chiovoloni-0/+40
2021-12-23Rollup merge of #88858 - spektom:to_lower_upper_rev, r=dtolnayMatthias Krüger-0/+31
Allow reverse iteration of lowercase'd/uppercase'd chars The PR implements `DoubleEndedIterator` trait for `ToLowercase` and `ToUppercase`. This enables reverse iteration of lowercase/uppercase variants of character sequences. One of use cases: determining whether a char sequence is a suffix of another one. Example: ```rust fn endswith_ignore_case(s1: &str, s2: &str) -> bool { for eob in s1 .chars() .flat_map(|c| c.to_lowercase()) .rev() .zip_longest(s2.chars().flat_map(|c| c.to_lowercase()).rev()) { match eob { EitherOrBoth::Both(c1, c2) => { if c1 != c2 { return false; } } EitherOrBoth::Left(_) => return true, EitherOrBoth::Right(_) => return false, } } true } ```
2021-12-14Fix a bunch of typosFrank Steffahn-1/+1
2021-11-18Make slice->str conversion and related functions constMaybe Waffle-3/+61
This commit makes the following functions from `core::str` `const fn`: - `from_utf8[_mut]` (`feature(const_str_from_utf8)`) - `from_utf8_unchecked_mut` (`feature(const_str_from_utf8_unchecked_mut)`) - `Utf8Error::{valid_up_to,error_len}` (`feature(const_str_from_utf8)`)
2021-10-30Add #[must_use] to remaining core functionsJohn Kugelman-1/+1
2021-09-11Allow reverse iteration of lowercase'd/uppercase'd charsMichael Spector-0/+31
2021-07-11Add test for the fixAlexis Bourget-0/+41
2021-06-18Lint for unused borrows as part of UNUSED_MUST_USEhi-rustin-5/+5
2021-02-03Fixes #80335Yechan Bae-0/+30
2020-12-02break formatting so rustfmt is happyRalf Jung-1/+2
2020-12-02disable a ptr equality test on MiriRalf Jung-1/+5
2020-11-30Make ui test that are run-pass and do not test the compiler itself library testsChristiaan Dirkx-1/+95
2020-10-20Check for exhaustion in SliceIndex for RangeInclusiveJosh Stone-0/+29
2020-09-05Move Various str tests in libraryAyush Kumar Mishra-0/+21
2020-07-28Add str::[r]split_onceAleksey Kladov-0/+24
This is useful for quick&dirty parsing of key: value config pairs
2020-07-27mv std libs to library/mark-0/+1899