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

Method repr_bytes

crates/vm/src/bytes_inner.rs:269–279  ·  view source on GitHub ↗
(&self, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

267 }
268
269 pub fn repr_bytes(&self, vm: &VirtualMachine) -> PyResult<String> {
270 let escape = crate::literal::escape::AsciiEscape::new_repr(&self.elements);
271 let len = 3 + escape
272 .layout()
273 .len
274 .ok_or_else(|| Self::new_repr_overflow_error(vm))?;
275 let mut buf = String::with_capacity(len);
276 escape.bytes_repr().write(&mut buf).unwrap();
277 debug_assert_eq!(buf.len(), len);
278 Ok(buf)
279 }
280
281 #[inline]
282 pub const fn len(&self) -> usize {

Callers 2

slot_strMethod · 0.80
repr_strMethod · 0.80

Calls 5

ok_or_elseMethod · 0.80
bytes_reprMethod · 0.80
layoutMethod · 0.45
unwrapMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected