mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 10:44:36 +08:00
char_indices() -> chars()
Co-Authored-By: Noah <33094578+coolreader18@users.noreply.github.com>
This commit is contained in:
1 parent
6ca457932b
commit
6bfd349ef6
1 file changed
+3
-3
@@ -407,12 +407,12 @@ impl PyString {
|
||||
|
||||
#[pymethod]
|
||||
fn capitalize(&self) -> String {
|
||||
let mut char_indices = self.value.char_indices();
|
||||
if let Some((_, first_char)) = char_indices.next() {
|
||||
let mut chars = self.value.chars();
|
||||
if let Some(first_char) = chars.next() {
|
||||
format!(
|
||||
"{}{}",
|
||||
first_char.to_uppercase(),
|
||||
&self.value[first_char.len_utf8()..].to_lowercase(),
|
||||
&chars.as_str().to_lowercase(),
|
||||
)
|
||||
} else {
|
||||
"".to_owned()
|
||||
|
||||
Reference in new issue
Block a user