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

Method translate

crates/vm/src/bytes_inner.rs:584–604  ·  view source on GitHub ↗
(
        &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

Callers 4

builtin_str.pyFile · 0.45
builtin_bytes.pyFile · 0.45
rust_strFunction · 0.45

Calls 6

newFunction · 0.85
get_valueMethod · 0.45
is_emptyMethod · 0.45
lenMethod · 0.45
containsMethod · 0.45
pushMethod · 0.45

Tested by 1

rust_strFunction · 0.36