File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 588588 b"they're bill's friends from the UK" .title ()
589589 == b"They'Re Bill'S Friends From The Uk"
590590)
591+
592+
593+ # repeat by multiply
594+ a = b'abcd'
595+ assert a * 0 == b''
596+ assert a * - 1 == b''
597+ assert a * 1 == b'abcd'
598+ assert a * 3 == b'abcdabcdabcd'
599+ assert 3 * a == b'abcdabcdabcd'
Original file line number Diff line number Diff line change @@ -403,6 +403,16 @@ impl PyBytesRef {
403403 fn title ( self , vm : & VirtualMachine ) -> PyResult {
404404 Ok ( vm. ctx . new_bytes ( self . inner . title ( ) ) )
405405 }
406+
407+ #[ pymethod( name = "__mul__" ) ]
408+ fn repeat ( self , n : PyIntRef , vm : & VirtualMachine ) -> PyResult {
409+ Ok ( vm. ctx . new_bytes ( self . inner . repeat ( n, vm) ?) )
410+ }
411+
412+ #[ pymethod( name = "__rmul__" ) ]
413+ fn rmul ( self , n : PyIntRef , vm : & VirtualMachine ) -> PyResult {
414+ self . repeat ( n, vm)
415+ }
406416}
407417
408418#[ pyclass]
You can’t perform that action at this time.
0 commit comments