about summary refs log tree commit diff
path: root/library/alloc/tests/str.rs
AgeCommit message (Collapse)AuthorLines
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