MCPcopy Create free account
hub / github.com/dylan-sutton-chavez/edge-python / format_value

Function format_value

compiler/src/modules/vm/handlers/format.rs:17–27  ·  view source on GitHub ↗
(v: Val, spec: &str, heap: &HeapPool)

Source from the content-addressed store, hash-verified

15}
16
17pub fn format_value(v: Val, spec: &str, heap: &HeapPool) -> Result<String, &'static str> {
18 if spec.is_empty() {
19 return Ok(display_inline(v, heap));
20 }
21 let parsed = parse_spec(spec)?;
22 // Cap against the heap budget; precision also below core::fmt's u16 abort threshold (panics at >= 65535).
23 const PRECISION_MAX: usize = 65_000;
24 if parsed.width > heap.limit() { return Err("format width exceeds limit"); }
25 if parsed.precision.is_some_and(|p| p > heap.limit().min(PRECISION_MAX)) { return Err("format precision exceeds limit"); }
26 apply(v, &parsed, heap)
27}
28
29#[derive(Default, Clone)]
30struct Spec {

Callers 3

str_percent_formatMethod · 0.85
format_opMethod · 0.85
formatFunction · 0.85

Calls 5

display_inlineFunction · 0.85
limitMethod · 0.80
parse_specFunction · 0.70
applyFunction · 0.70
is_emptyMethod · 0.45

Tested by

no test coverage detected