xpile 0.1.615

Polyglot transpile workbench (Python/C/C++/Rust/Ruchy/Lean ↔ Rust/Ruchy/PTX/WGSL/SPIR-V) with provable contracts at every layer.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# PMAT-502am (Tranche 2): f-string format specs -> Rust format! specs.
# Supported subset: .Nf (float), 0Nd/Nd (int width/zero-pad), >N/<N/^N (align).
def price(x: float) -> str:
    return f"${x:.2f}"


def padded(n: int) -> str:
    return f"[{n:05d}]"


def aligned(name: str) -> str:
    return f"|{name:>8}|"


def width(n: int) -> str:
    return f"{n:4d}"