File tree 2 files changed +11
-0
lines changed 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change 65
65
pass
66
66
else :
67
67
assert False
68
+
69
+ a = bytearray (b'appen' )
70
+ assert len (a ) == 5
71
+ a .append (100 )
72
+ assert len (a ) == 6
73
+ assert a .pop () == 100
Original file line number Diff line number Diff line change @@ -79,6 +79,7 @@ pub fn init(context: &PyContext) {
79
79
"istitle" =>context. new_rustfunc( PyByteArrayRef :: istitle) ,
80
80
"isupper" => context. new_rustfunc( PyByteArrayRef :: isupper) ,
81
81
"lower" => context. new_rustfunc( PyByteArrayRef :: lower) ,
82
+ "append" => context. new_rustfunc( PyByteArrayRef :: append) ,
82
83
"pop" => context. new_rustfunc( PyByteArrayRef :: pop) ,
83
84
"upper" => context. new_rustfunc( PyByteArrayRef :: upper)
84
85
} ) ;
@@ -213,6 +214,10 @@ impl PyByteArrayRef {
213
214
self . value . borrow_mut ( ) . clear ( ) ;
214
215
}
215
216
217
+ fn append ( self , x : u8 , _vm : & VirtualMachine ) {
218
+ self . value . borrow_mut ( ) . push ( x) ;
219
+ }
220
+
216
221
fn pop ( self , vm : & VirtualMachine ) -> PyResult < u8 > {
217
222
let mut bytes = self . value . borrow_mut ( ) ;
218
223
bytes
You can’t perform that action at this time.
0 commit comments