◐ Shell
reader mode source ↗
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
File filter
Conversations
Jump to
Diff view
Apply and reload
Show whitespace
Diff view
Apply and reload
10 changes: 0 additions & 10 deletions Lib/test/test_bigmem.py
Original file line number Diff line number Diff line change
Expand Up @@ -765,16 +765,6 @@ def test_translate(self, size):
self.assertEqual(s.count(_('!')), repeats * 2)
self.assertEqual(s.count(_('z')), repeats * 3)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_lstrip(self, size):
super().test_lstrip(size)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_rstrip(self, size):
super().test_rstrip(size)


class BytesTest(unittest.TestCase, BaseStrTest):

Expand Down
48 changes: 32 additions & 16 deletions vm/src/builtins/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -592,25 +592,41 @@ impl PyStr {
}

#[pymethod]
fn lstrip(&self, chars: OptionalOption<PyStrRef>) -> String {
self.as_str()
.py_strip(
chars,
|s, chars| s.trim_start_matches(|c| chars.contains(c)),
|s| s.trim_start(),
)
.to_owned()
}

#[pymethod]
fn rstrip(&self, chars: OptionalOption<PyStrRef>) -> String {
self.as_str()
.py_strip(
chars,
|s, chars| s.trim_end_matches(|c| chars.contains(c)),
|s| s.trim_end(),
)
.to_owned()
}

#[pymethod]
Expand Down
Toggle all file notes Toggle all file annotations