(zelf: &Py<Self>, vm: &VirtualMachine)
| 560 | impl Representable for PyDeque { |
| 561 | #[inline] |
| 562 | fn repr(zelf: &Py<Self>, vm: &VirtualMachine) -> PyResult<PyRef<PyStr>> { |
| 563 | let deque = zelf.borrow_deque().clone(); |
| 564 | let class = zelf.class(); |
| 565 | let class_name = class.name(); |
| 566 | let closing_part = zelf |
| 567 | .maxlen |
| 568 | .map(|maxlen| format!("], maxlen={maxlen}")) |
| 569 | .unwrap_or_else(|| "]".to_owned()); |
| 570 | |
| 571 | if zelf.__len__() == 0 { |
| 572 | return Ok(vm.ctx.new_str(format!("{class_name}([{closing_part})"))); |
| 573 | } |
| 574 | if let Some(_guard) = ReprGuard::enter(vm, zelf.as_object()) { |
| 575 | Ok(vm.ctx.new_str(collection_repr( |
| 576 | Some(&class_name), |
| 577 | "[", |
| 578 | &closing_part, |
| 579 | deque.iter(), |
| 580 | vm, |
| 581 | )?)) |
| 582 | } else { |
| 583 | Ok(vm.ctx.intern_str("[...]").to_owned()) |
| 584 | } |
| 585 | } |
| 586 | |
| 587 | fn repr_str(_zelf: &Py<Self>, _vm: &VirtualMachine) -> PyResult<String> { |
| 588 | unreachable!("repr() is overridden directly") |
no test coverage detected