diff options
| author | Oli Scherer <github333195615777966@oli-obk.de> | 2025-07-11 08:37:09 +0000 |
|---|---|---|
| committer | Oli Scherer <github333195615777966@oli-obk.de> | 2025-07-15 07:58:29 +0000 |
| commit | cb7d52f6430922b5ffd29073f6605b19b80e7f36 (patch) | |
| tree | fdf2a27e0f7af1859fe8fc6085be439856cb171e /library/core/src/str/mod.rs | |
| parent | b5230e53604f1227a087397e561e1cd2329f59b6 (diff) | |
| download | rust-cb7d52f6430922b5ffd29073f6605b19b80e7f36.tar.gz rust-cb7d52f6430922b5ffd29073f6605b19b80e7f36.zip | |
constify some methods using `SliceIndex`
Diffstat (limited to 'library/core/src/str/mod.rs')
| -rw-r--r-- | library/core/src/str/mod.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/library/core/src/str/mod.rs b/library/core/src/str/mod.rs index fba3436496e..bb0106b9fd9 100644 --- a/library/core/src/str/mod.rs +++ b/library/core/src/str/mod.rs @@ -589,8 +589,9 @@ impl str { /// assert!(v.get(..42).is_none()); /// ``` #[stable(feature = "str_checked_slicing", since = "1.20.0")] + #[rustc_const_unstable(feature = "const_index", issue = "143775")] #[inline] - pub fn get<I: SliceIndex<str>>(&self, i: I) -> Option<&I::Output> { + pub const fn get<I: ~const SliceIndex<str>>(&self, i: I) -> Option<&I::Output> { i.get(self) } @@ -621,8 +622,9 @@ impl str { /// assert_eq!("HEllo", v); /// ``` #[stable(feature = "str_checked_slicing", since = "1.20.0")] + #[rustc_const_unstable(feature = "const_index", issue = "143775")] #[inline] - pub fn get_mut<I: SliceIndex<str>>(&mut self, i: I) -> Option<&mut I::Output> { + pub const fn get_mut<I: ~const SliceIndex<str>>(&mut self, i: I) -> Option<&mut I::Output> { i.get_mut(self) } |
