`format(v, spec)` dispatch: instance `__format__(spec)` wins; otherwise the built-in spec engine runs. Empty spec on an instance still goes through `__format__` so user formatting can opt in. */
(&mut self, v: Val, spec: &str, chunk: &SSAChunk, slots: &mut [Val])
| 358 | |
| 359 | /* `format(v, spec)` dispatch: instance `__format__(spec)` wins; otherwise the built-in spec engine runs. Empty spec on an instance still goes through `__format__` so user formatting can opt in. */ |
| 360 | pub(crate) fn format_op(&mut self, v: Val, spec: &str, chunk: &SSAChunk, slots: &mut [Val]) -> Result<String, VmErr> { |
| 361 | if v.is_heap() && matches!(self.heap.get(v), HeapObj::Instance(..)) { |
| 362 | let spec_val = self.heap.alloc(HeapObj::Str(spec.to_string()))?; |
| 363 | if let Some(r) = self.try_call_dunder(v, "__format__", &[spec_val], chunk, slots)? { |
| 364 | return self.require_str(r, "__format__"); |
| 365 | } |
| 366 | } |
| 367 | super::format::format_value(v, spec, &self.heap).map_err(super::format::fmt_err) |
| 368 | } |
| 369 | |
| 370 | /* Coerce a `__len__` / `__length_hint__` return value to bool semantics; rejects negatives. */ |
| 371 | fn len_to_bool(&self, v: Val) -> Result<bool, VmErr> { |
no test coverage detected