MCPcopy Index your code
hub / github.com/RustPython/RustPython / write_byte

Method write_byte

crates/stdlib/src/mmap.rs:1381–1398  ·  view source on GitHub ↗
(&self, byte: PyObjectRef, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

1379
1380 #[pymethod]
1381 fn write_byte(&self, byte: PyObjectRef, vm: &VirtualMachine) -> PyResult<()> {
1382 let b = value_from_object(vm, &byte)?;
1383
1384 let pos = self.pos();
1385 let size = self.__len__();
1386
1387 if pos >= size {
1388 return Err(vm.new_value_error("write byte out of range"));
1389 }
1390
1391 self.try_writable(vm, |mmap| {
1392 mmap[pos] = b;
1393 })?;
1394
1395 self.advance_pos(1);
1396
1397 Ok(())
1398 }
1399
1400 fn __getitem__(&self, needle: PyObjectRef, vm: &VirtualMachine) -> PyResult<PyObjectRef> {
1401 self.getitem_inner(&needle, vm)

Callers 3

test_access_parameterMethod · 0.80
test_io_methodsMethod · 0.80
test_non_ascii_byteMethod · 0.80

Calls 6

value_from_objectFunction · 0.85
try_writableMethod · 0.80
advance_posMethod · 0.80
ErrClass · 0.50
posMethod · 0.45
__len__Method · 0.45

Tested by 3

test_access_parameterMethod · 0.64
test_io_methodsMethod · 0.64
test_non_ascii_byteMethod · 0.64