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

Method maketrans

crates/vm/src/bytes_inner.rs:567–582  ·  view source on GitHub ↗
(from: Self, to: Self, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

565 }
566
567 pub fn maketrans(from: Self, to: Self, vm: &VirtualMachine) -> PyResult<Vec<u8>> {
568 if from.len() != to.len() {
569 return Err(vm.new_value_error("the two maketrans arguments must have equal length"));
570 }
571 let mut res = vec![];
572
573 for i in 0..=u8::MAX {
574 res.push(if let Some(position) = from.elements.find_byte(i) {
575 to.elements[position]
576 } else {
577 i
578 });
579 }
580
581 Ok(res)
582 }
583
584 pub fn translate(
585 &self,

Callers 14

b64encodeFunction · 0.45
b64decodeFunction · 0.45
base64.pyFile · 0.45
_b32decodeFunction · 0.45
__init__Method · 0.45
test_maketransMethod · 0.45
test_translateMethod · 0.45
TestParserClass · 0.45

Calls 3

ErrClass · 0.50
lenMethod · 0.45
pushMethod · 0.45

Tested by 3

test_maketransMethod · 0.36
test_translateMethod · 0.36