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

Method _pad

crates/vm/src/bytes_inner.rs:502–515  ·  view source on GitHub ↗
(
        &self,
        options: ByteInnerPaddingOptions,
        pad: fn(&[u8], usize, u8, usize) -> Vec<u8>,
        vm: &VirtualMachine,
    )

Source from the content-addressed store, hash-verified

500
501 #[inline]
502 fn _pad(
503 &self,
504 options: ByteInnerPaddingOptions,
505 pad: fn(&[u8], usize, u8, usize) -> Vec<u8>,
506 vm: &VirtualMachine,
507 ) -> PyResult<Vec<u8>> {
508 let (width, fillchar) = options.get_value("center", vm)?;
509 let len = self.len();
510 Ok(if len as isize >= width {
511 Vec::from(&self.elements[..])
512 } else {
513 pad(&self.elements, width as usize, fillchar, len)
514 })
515 }
516
517 pub fn center(
518 &self,

Callers 3

centerMethod · 0.45
ljustMethod · 0.45
rjustMethod · 0.45

Calls 2

get_valueMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected