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

Method py_pad

crates/vm/src/anystr.rs:280–288  ·  view source on GitHub ↗
(&self, left: usize, right: usize, fillchar: Self::Char)

Source from the content-addressed store, hash-verified

278 }
279
280 fn py_pad(&self, left: usize, right: usize, fillchar: Self::Char) -> Self::Container {
281 let mut u = Self::Container::with_capacity(
282 (left + right) * fillchar.bytes_len() + self.bytes_len(),
283 );
284 u.extend(core::iter::repeat_n(fillchar, left));
285 u.push_str(self);
286 u.extend(core::iter::repeat_n(fillchar, right));
287 u
288 }
289
290 fn py_center(&self, width: usize, fillchar: Self::Char, len: usize) -> Self::Container {
291 let marg = width - len;

Callers 3

py_centerMethod · 0.80
py_ljustMethod · 0.80
py_rjustMethod · 0.80

Implementers 2

bytes_inner.rscrates/vm/src/bytes_inner.rs
str.rscrates/vm/src/builtins/str.rs

Calls 3

bytes_lenMethod · 0.45
extendMethod · 0.45
push_strMethod · 0.45

Tested by

no test coverage detected