MCPcopy Create free account
hub / github.com/argumentcomputer/ix / fmt_univ

Function fmt_univ

crates/kernel/src/level.rs:263–300  ·  view source on GitHub ↗
(
  u: &KUniv<M>,
  f: &mut fmt::Formatter<'_>,
)

Source from the content-addressed store, hash-verified

261impl<M: KernelMode> Eq for KUniv<M> {}
262
263/// Meta mode: shows names when available, positional index as fallback.
264/// Anon mode: shows positional parameter indices.
265impl<M: KernelMode> fmt::Display for KUniv<M> {
266 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
267 fmt_univ(self, f)
268 }
269}
270
271fn fmt_univ<M: KernelMode>(
272 u: &KUniv<M>,
273 f: &mut fmt::Formatter<'_>,
274) -> fmt::Result {
275 match u.data() {
276 UnivData::Zero(_) => write!(f, "0"),
277 UnivData::Succ(_, _) => {
278 let (base, n) = u.offset();
279 if base.is_zero() {
280 write!(f, "{n}")
281 } else {
282 fmt_univ(base, f)?;
283 write!(f, "+{n}")
284 }
285 },
286 UnivData::Max(a, b, _) => {
287 write!(f, "max(")?;
288 fmt_univ(a, f)?;
289 write!(f, ", ")?;
290 fmt_univ(b, f)?;
291 write!(f, ")")
292 },
293 UnivData::IMax(a, b, _) => {
294 write!(f, "imax(")?;
295 fmt_univ(a, f)?;
296 write!(f, ", ")?;
297 fmt_univ(b, f)?;
298 write!(f, ")")
299 },
300 UnivData::Param(idx, name, _) => {
301 if name.has_meta() {
302 name.meta_fmt(f)
303 } else {

Callers 1

fmtMethod · 0.85

Calls 5

offsetMethod · 0.80
is_zeroMethod · 0.80
dataMethod · 0.45
has_metaMethod · 0.45
meta_fmtMethod · 0.45

Tested by

no test coverage detected