Method
maketrans
(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, |