Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 12 pull requests #132317

Merged
merged 29 commits into from
Oct 29, 2024
Merged
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
8ee548f
const fn str::is_char_boundary
zachs18 Oct 23, 2024
aa493d0
const fn str::split_at*
zachs18 Oct 23, 2024
6ab87f8
Collect item bounds for RPITITs from trait where clauses just like as…
compiler-errors Oct 26, 2024
e4f793a
riscv-soft-abi-with-float-features.rs: adapt for LLVM 20
krasimirgg Oct 28, 2024
0bff994
split clippy task for library and compiler, so different lints can be…
klensy Oct 7, 2024
746b675
fix clippy::clone_on_ref_ptr for compiler
klensy Oct 7, 2024
a946721
clarified doc for `std::fs::OpenOptions.truncate()`
yakiimoninja Oct 28, 2024
5910a4f
clarified std::fs truncate doc
yakiimoninja Oct 28, 2024
d4774ff
Remove my ping for rustdoc/clean/types.rs
camelid Oct 28, 2024
b2f335e
Split `boxed.rs` into a few modules
WaffleLapkin Oct 27, 2024
f0744ca
Bless a miri test
WaffleLapkin Oct 28, 2024
5ae5323
Remove myself from mentions inside `tests/ui/check-cfg` directory
Urgau Oct 28, 2024
8b7b8e5
Hack out effects support for old solver
compiler-errors Oct 22, 2024
1763637
correct LLVMRustCreateThinLTOData arg types
klensy Oct 27, 2024
2b326e3
correct LLVMRustDIBuilderCreateOpLLVMFragment return type
klensy Oct 27, 2024
6c93c65
Delete `tests/crashes/23707.rs` because it's flaky
jieyouxu Oct 29, 2024
6f82a95
Rename `command-list.rs` to `directive-list.rs`
Zalathar Oct 29, 2024
5d0f52e
Rollup merge of #131375 - klensy:clone_on_ref_ptr, r=cjgillot
workingjubilee Oct 29, 2024
b496974
Rollup merge of #131520 - zachs18:const-str-split, r=Noratrieb
workingjubilee Oct 29, 2024
e97286e
Rollup merge of #132119 - compiler-errors:effects-old-solver, r=lcnr
workingjubilee Oct 29, 2024
b8f08fe
Rollup merge of #132194 - compiler-errors:rpitit-super-wc, r=spastorino
workingjubilee Oct 29, 2024
a70b90b
Rollup merge of #132216 - klensy:c_uint, r=cuviper
workingjubilee Oct 29, 2024
5ee13ae
Rollup merge of #132233 - WaffleLapkin:box-module-split, r=workingjub…
workingjubilee Oct 29, 2024
423d4f0
Rollup merge of #132266 - krasimirgg:llvm-20-testfix, r=hanna-kruppe,…
workingjubilee Oct 29, 2024
29a7ca9
Rollup merge of #132270 - yakiimoninja:fs-truncate-docs, r=Noratrieb
workingjubilee Oct 29, 2024
3eb7ddd
Rollup merge of #132284 - camelid:rm-ping, r=workingjubilee
workingjubilee Oct 29, 2024
9d58475
Rollup merge of #132293 - Urgau:tests-check-cfg-out-triagebot, r=lqd
workingjubilee Oct 29, 2024
0963636
Rollup merge of #132312 - jieyouxu:delete-crashes-23707, r=matthiaskrgr
workingjubilee Oct 29, 2024
6c5641c
Rollup merge of #132313 - Zalathar:directive-list, r=jieyouxu
workingjubilee Oct 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
const fn str::is_char_boundary
  • Loading branch information
zachs18 committed Oct 23, 2024
commit 8ee548fcf01ea4aa5b17f6daef6f2f86c2f6fde5
13 changes: 7 additions & 6 deletions library/core/src/str/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,9 @@ impl str {
/// ```
#[must_use]
#[stable(feature = "is_char_boundary", since = "1.9.0")]
#[rustc_const_unstable(feature = "const_is_char_boundary", issue = "131516")]
#[inline]
pub fn is_char_boundary(&self, index: usize) -> bool {
pub const fn is_char_boundary(&self, index: usize) -> bool {
// 0 is always ok.
// Test for 0 explicitly so that it can optimize out the check
// easily and skip reading string data for that case.
Expand All @@ -195,8 +196,8 @@ impl str {
return true;
}

match self.as_bytes().get(index) {
// For `None` we have two options:
if index >= self.len() {
// For `true` we have two options:
//
// - index == self.len()
// Empty strings are valid, so return true
Expand All @@ -205,9 +206,9 @@ impl str {
//
// The check is placed exactly here, because it improves generated
// code on higher opt-levels. See PR #84751 for more details.
None => index == self.len(),

Some(&b) => b.is_utf8_char_boundary(),
index == self.len()
} else {
self.as_bytes()[index].is_utf8_char_boundary()
}
}

Expand Down