Method
translate
(
&self,
options: ByteInnerTranslateOptions,
vm: &VirtualMachine,
)
Source from the content-addressed store, hash-verified
| 582 | } |
| 583 | |
| 584 | pub fn translate( |
| 585 | &self, |
| 586 | options: ByteInnerTranslateOptions, |
| 587 | vm: &VirtualMachine, |
| 588 | ) -> PyResult<Vec<u8>> { |
| 589 | let (table, delete) = options.get_value(vm)?; |
| 590 | |
| 591 | let mut res = if delete.is_empty() { |
| 592 | Vec::with_capacity(self.elements.len()) |
| 593 | } else { |
| 594 | Vec::new() |
| 595 | }; |
| 596 | |
| 597 | for i in &self.elements { |
| 598 | if !delete.contains(i) { |
| 599 | res.push(table[*i as usize]); |
| 600 | } |
| 601 | } |
| 602 | |
| 603 | Ok(res) |
| 604 | } |
| 605 | |
| 606 | pub fn strip(&self, chars: OptionalOption<Self>) -> Vec<u8> { |
| 607 | self.elements |