Method
_pad
(
&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, |
Tested by
no test coverage detected