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

Function format_char

compiler/src/modules/vm/handlers/format.rs:172–179  ·  view source on GitHub ↗
(v: Val, s: &Spec)

Source from the content-addressed store, hash-verified

170}
171
172fn format_char(v: Val, s: &Spec) -> Result<String, &'static str> {
173 if !v.is_int() { return Err("'c' format spec requires an integer"); }
174 let i = v.as_int();
175 if !(0..=0x10FFFF).contains(&i) { return Err(C_RANGE_ERR); }
176 let ch = char::from_u32(i as u32).ok_or("'c' format spec arg not a valid char")?;
177 // 'c' is numeric for alignment: it defaults to right-align like ints.
178 Ok(pad_aligned(s, &ch.to_string(), 0))
179}
180
181fn format_int(v: Val, s: &Spec, heap: &HeapPool) -> Result<String, &'static str> {
182 let (neg, mag) = int_to_decimal_parts(v, heap)?;

Callers 1

applyFunction · 0.85

Calls 4

pad_alignedFunction · 0.85
is_intMethod · 0.80
as_intMethod · 0.80
containsMethod · 0.45

Tested by

no test coverage detected