Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion quest/m3/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ generic std gap is planned here even when moq never calls it.
- [Equality of std containers of unlike elements](/quest/m3/ts-eq-unlike.md) - `==` and `next_if_eq` of a `Vec<Left>` against a `&[Right]`, and of `VecDeque` against `Vec`, translate
- [Waiting: a slice object for a mutable part of other values](/quest/m3/ts-slice-object.md) - waits on a moq profile showing the `Proxy` view's traps matter, then decides on an `rt.ByteSlice`-like form
- [Port the workflow guard to kixelated/quest](/quest/m3/quest-workflow-guard.md) - quest's environment guard parses YAML as this repository's does
- [A VecDeque's Debug](/quest/m3/ts-deque-debug.md) - `{:?}` of a `VecDeque` translates, writing std's list
- [std iterators' Debug](/quest/m3/ts-iter-debug.md) - `{:?}` of std's iterators translates, writing std's text, a deque's two slices included
- [LinkedList](/quest/m3/ts-linked-list.md) - `LinkedList` and its methods translate
- [A parameter read only where lowering leaves nothing](/quest/m3/ts-unread-params.md) - an instance whose lowering drops every read of a parameter marks it unused, so `tsc` accepts it
- [std's impls of its zero-sized types](/quest/m3/ts-zero-sized-impls.md) - `PhantomData`'s derived impls translate, and `()` is a hash or B-tree key
- [Array keys a collection holds](/quest/m3/ts-array-keys.md) - collections of `[T; N]` keys type-check
Expand Down
15 changes: 0 additions & 15 deletions quest/m3/ts-deque-debug.md

This file was deleted.

23 changes: 23 additions & 0 deletions quest/m3/ts-iter-debug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# [S] std iterators' Debug

## Goal

[rust2-ts](/ts/README.md) translates `{:?}` of std's iterators, writing the same text as
std, proven by differential tests against native Rust.

## Plan

Found auditing std collections' `Debug`: each of these refuses with `unsupported call to
<... as Debug>::fmt`, while the collections themselves translate.

- `slice::Iter`, `vec::IntoIter`, and `binary_heap::Iter` write their remaining items as a
tuple of one slice: `Iter([1, 2])`.
- `str::Chars` writes `Chars(['a', 'b'])`, and `str::Bytes` its adaptor chain:
`Bytes(Copied { it: Iter([97]) })`.
- `btree_map`'s `Iter`, `Keys`, and `Values`, `btree_set::Iter`, and `hash_map`'s and
`hash_set`'s write their remaining entries as a list or map, without a name.
- `vec_deque::Iter` writes the two slices of its ring buffer, `Iter([3], [1, 2])`, as
`VecDeque::as_slices` returns them. Both need the runtime's buffer to split where
std's does, by the same growth and head; `as_slices` is refused too.

Public API: the translator's output.
14 changes: 14 additions & 0 deletions quest/m3/ts-linked-list.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# [M] LinkedList

## Goal

[rust2-ts](/ts/README.md) translates `std::collections::LinkedList` and its methods,
`Debug` included, proven by differential tests against native Rust.

## Plan

Found auditing std collections' `Debug`: any use refuses with `unsupported type
std::collections::LinkedList from another crate`. No consumer calls it yet; it is planned
here as part of std.

Public API: the translator's output.
3 changes: 2 additions & 1 deletion ts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ core's too, failing with an `rt.ParseBoolError`; a `char`'s is `rt.charFromStr`,
an `rt.ParseCharError`, `{ kind }`, its private `CharErrorKind`'s name. `==` of a `Result`
and of std's errors is their derived `PartialEq`, from core's MIR, so two errors are equal
where their kinds are, private or not. `Debug` of a string or `char` escapes by
std's Unicode tables, which the runtime carries, not the engine's. A caller prints a
std's Unicode tables, which the runtime carries, not the engine's. `Debug` of std's
collections writes their items in the order each iterates, a hash map's or set's included. A caller prints a
`printable` type as `to_string()` and `format!("{err:?}")`
would: `rt.fmtToString((f) => DecodeError.fmt$Display(err, f))` and
`rt.fmtFormat([(f) => DecodeError.fmt$Debug(err, f)])`, after
Expand Down
91 changes: 91 additions & 0 deletions ts/fixtures/lang/expected/fmt.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Generated by rust2-ts. Do not edit.

import * as rt from "./rt.ts";
import { thenSome$0d5am30 } from "./core/bool.ts";
import { unwrapOr$0k15iai, unwrapOr$0r2bmpr } from "./core/option.ts";
import * as Bare from "./fmt.Bare.ts";
import * as Braced from "./fmt.Braced.ts";
Expand Down Expand Up @@ -716,6 +717,96 @@ export function wrapped(data: rt.ByteSlice, out: rt.ByteVec): void {
arc[Symbol.dispose]();
}

/**
* std's collections' `Debug`, which passes its options to each element: a deque from its
* head however its buffer wraps, sets and maps in braces, nested, and pretty. A hash
* collection holds at most one entry, since std leaves their order unspecified.
*/
export function collections(data: rt.ByteSlice, out: rt.ByteVec): void {
const at: (a0: rt.usize) => rt.u8 = (i: rt.usize): rt.u8 => {
return unwrapOr$0r2bmpr(rt.byteSliceGet(data, i), 0);
};
const q: rt.VecDeque<rt.u8 | undefined> = rt.dequeNew() as rt.VecDeque<rt.u8 | undefined>;
for (const b of rt.byteSliceView(data)) {
const _12: rt.u8 = rt.u8Rem(b, 4);
if (_12 === 0) {
const _15: rt.u8 | undefined = thenSome$0d5am30(rt.u8Rem(b, 3) !== 0, b);
rt.dequePushBack(q, _15);
} else if (_12 === 1) {
const _20: rt.u8 | undefined = thenSome$0d5am30(rt.u8Rem(b, 3) !== 0, b);
rt.dequePushFront(q, _20);
} else if (_12 === 2) {
rt.dequePopBack(q, rt.None);
} else {
rt.dequePopFront(q, rt.None);
}
}
const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(rt.dequeIter(q), f, (value: rt.u8 | undefined, f: rt.Formatter) => rt.fmtOption(value, f, rt.u8Debug))];
put(out, rt.fmtFormat([args2[0], "|", rt.fmtSpec({ alternate: true }, args2[0]), "|", rt.fmtSpec({ debugHex: "x" }, args2[0]), "|", rt.fmtSpec({ align: ">", width: 4 }, args2[0])]));
const wrapped_: rt.VecDeque<Hex.Hex> = rt.dequeNew() as rt.VecDeque<Hex.Hex>;
rt.dequeExtend(wrapped_, rt.iterSlice([{ _0: 1 }, { _0: 2 }]), undefined, 4, true);
const _48: Hex.Hex = { _0: rt.u32Mul(at(0) as rt.u32, 4097) };
rt.dequePushFront(wrapped_, _48);
const _57: Hex.Hex = { _0: at(1) as rt.u32 };
rt.dequePushFront(wrapped_, _57);
rt.dequePopBack(wrapped_);
const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(rt.dequeIter(wrapped_), f, (value: Hex.Hex, f: rt.Formatter) => Hex.fmt$Debug(value, f))];
const mid: string = rt.fmtFormat([args4[0]]);
rt.dequePopBack(wrapped_);
const args6: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, mid), (f: rt.Formatter) => rt.fmtList(rt.dequeIter(wrapped_), f, (value: Hex.Hex, f: rt.Formatter) => Hex.fmt$Debug(value, f))];
put(out, rt.fmtFormat([args6[0], "|", args6[1], "|", rt.fmtSpec({ alternate: true }, args6[1]), "|", rt.fmtSpec({ width: 6 }, args6[1])]));
const empty: rt.VecDeque<rt.u8> = rt.dequeNew() as rt.VecDeque<rt.u8>;
const _91: rt.Iter<undefined> = rt.iterMap(new rt.Range(0, rt.u8Rem(at(2), 3)), (_2: rt.u8): undefined => {});
const units: rt.VecDeque<undefined> = rt.dequeExtend(rt.dequeNew() as rt.VecDeque<undefined>, _91, undefined, 0, true);
const args8: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(rt.dequeIter(empty), f, rt.u8Debug), (f: rt.Formatter) => rt.fmtList(rt.dequeIter(units), f, rt.fmtUnit)];
put(out, rt.fmtFormat([args8[0], "|", rt.fmtSpec({ alternate: true }, args8[0]), "|", args8[1]]));
const _114: rt.VecDeque<Pair.Pair> = rt.dequeNew() as rt.VecDeque<Pair.Pair>;
const _116: Pair.Pair[] = [{ _0: at(3), _1: -1 }, { _0: 2, _1: 3 }];
const _113: rt.VecDeque<Pair.Pair>[] = [_114, rt.dequeExtend(rt.dequeNew() as rt.VecDeque<Pair.Pair>, rt.iterSlice(_116), undefined, 16, true)];
const part = rt.dequeExtend(rt.dequeNew() as rt.VecDeque<rt.VecDeque<Pair.Pair>>, rt.iterSlice(_113), undefined, 16, true);
const args10: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(rt.dequeIter(part), f, (value: rt.VecDeque<Pair.Pair>, f: rt.Formatter) => rt.fmtList(rt.dequeIter(value), f, (value: Pair.Pair, f: rt.Formatter) => Pair.fmt$Debug(value, f)))];
put(out, rt.fmtFormat([args10[0], "|", rt.fmtSpec({ alternate: true }, args10[0])]));
const _135: rt.Iter<rt.u8 | undefined> = rt.iterMap(rt.iterSlice(rt.byteSliceView(data)), (_25: rt.u8): rt.u8 | undefined => {
const b5: rt.u8 = _25;
return thenSome$0d5am30(rt.u8Rem(b5, 3) !== 0, rt.u8Rem(b5, 8));
});
const part2 = rt.btreeExtendKeys(rt.btreeNew(rt.cmpOption(rt.cmp)) as rt.BTreeSet<rt.u8 | undefined>, _135, true, undefined, undefined, 2, true);
const args12: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtSet(rt.btreeKeys(part2), f, (value: rt.u8 | undefined, f: rt.Formatter) => rt.fmtOption(value, f, rt.u8Debug))];
put(out, rt.fmtFormat([args12[0], "|", rt.fmtSpec({ alternate: true }, args12[0]), "|", rt.fmtSpec({ zero: true, debugHex: "x", width: 2 }, args12[0])]));
const map: rt.BTreeMap<rt.u8, rt.VecDeque<Pair.Pair>> = rt.btreeNew(rt.cmp) as rt.BTreeMap<rt.u8, rt.VecDeque<Pair.Pair>>;
const iter2: rt.Iter<rt.u8> = rt.iterTake(rt.iterSlice(rt.byteSliceView(data)), 6);
while (true) {
const _154: rt.u8 | rt.Done = iter2.next();
if (_154 === rt.DONE) {
break;
}
const b2: rt.u8 = _154;
rt.dequePushFront(rt.entryOrInsertWith(rt.entry(map, rt.u8Rem(b2, 4)), (): rt.VecDeque<Pair.Pair> => {
return rt.dequeNew() as rt.VecDeque<Pair.Pair>;
}), { _0: b2, _1: rt.i64Neg(b2 as rt.i64) });
}
const _176: rt.BTreeMap<rt.u8, rt.u8> = rt.btreeNew(rt.cmp) as rt.BTreeMap<rt.u8, rt.u8>;
const _178: rt.BTreeSet<rt.u8> = rt.btreeNew(rt.cmp) as rt.BTreeSet<rt.u8>;
const args14: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtMap(rt.btreeIter(map), f, rt.u8Debug, (value: rt.VecDeque<Pair.Pair>, f: rt.Formatter) => rt.fmtList(rt.dequeIter(value), f, (value: Pair.Pair, f: rt.Formatter) => Pair.fmt$Debug(value, f))), (f: rt.Formatter) => rt.fmtMap(rt.btreeIter(_176), f, rt.u8Debug, rt.u8Debug), (f: rt.Formatter) => rt.fmtSet(rt.btreeKeys(_178), f, rt.u8Debug)];
put(out, rt.fmtFormat([args14[0], "|", rt.fmtSpec({ alternate: true }, args14[0]), "|", args14[1], "|", rt.fmtSpec({ alternate: true }, args14[2])]));
const _188: [rt.HashMap<rt.u8 | undefined, Hex.Hex>, rt.HashSet<rt.u8>] = [rt.hashNew(rt.hashing(rt.hashOption(rt.hash8), rt.same)) as rt.HashMap<rt.u8 | undefined, Hex.Hex>, rt.hashNew() as rt.HashSet<rt.u8>];
const one: rt.HashMap<rt.u8 | undefined, Hex.Hex> = _188[0];
const set: rt.HashSet<rt.u8> = _188[1];
const _191: rt.u8 | undefined = rt.byteSliceFirst(data);
if (_191 !== undefined) {
const b3: rt.u8 = _191;
const _196: rt.u8 | undefined = thenSome$0d5am30(rt.u8Rem(b3, 2) === 0, b3);
const _200: Hex.Hex = { _0: b3 as rt.u32 };
rt.hashInsert(one, _196, _200);
}
const _202: rt.u8 | undefined = rt.byteSliceGet(data, 1);
if (_202 !== undefined) {
rt.hashAdd(set, _202);
}
const args16: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtMap(rt.hashIter(one), f, (value: rt.u8 | undefined, f: rt.Formatter) => rt.fmtOption(value, f, rt.u8Debug), (value: Hex.Hex, f: rt.Formatter) => Hex.fmt$Debug(value, f)), (f: rt.Formatter) => rt.fmtSet(rt.hashKeys(set), f, rt.u8Debug)];
put(out, rt.fmtFormat([args16[0], "|", rt.fmtSpec({ alternate: true }, args16[0]), "|", rt.fmtSpec({ align: ">", width: 3 }, args16[0]), "|", args16[1], "|", rt.fmtSpec({ alternate: true }, args16[1]), "|", rt.fmtSpec({ alternate: true, zero: true, debugHex: "x", width: 4 }, args16[1])]));
}

/**
* Literals, a `char` of each width, and empty pieces, each its own call, stopping at the
* first error.
Expand Down
6 changes: 4 additions & 2 deletions ts/fixtures/lang/expected/harness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { dyns, shared, anys, fns } from "./dyns.ts";
import { edits, bytes } from "./edits.ts";
import { eqs } from "./errors.ts";
import { floats, mulAdds, formats, parses } from "./floats.ts";
import { ints, strings, derived, written, counts, rounding, panics, wrapped, writes } from "./fmt.ts";
import { ints, strings, derived, written, counts, rounding, panics, wrapped, collections, writes } from "./fmt.ts";
import { folds } from "./folds.ts";
import { methods } from "./generics.ts";
import { values, random, bytes as hashes_bytes } from "./hashes.ts";
Expand Down Expand Up @@ -192,7 +192,9 @@ export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec)
maps(data69, out70);
}] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["arrays::lent", (_2170: rt.u8, data70: rt.ByteSlice, out71: rt.ByteVec): undefined => {
lent(data70, out71);
}] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["floats::mul_adds", mulAdds as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["singles::mul_adds", singles_mulAdds as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]];
}] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["floats::mul_adds", mulAdds as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["singles::mul_adds", singles_mulAdds as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["fmt::collections", (_2171: rt.u8, data71: rt.ByteSlice, out72: rt.ByteVec): undefined => {
collections(data71, out72);
}] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]];
}

/** Run one case. */
Expand Down
61 changes: 61 additions & 0 deletions ts/fixtures/lang/src/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#![allow(dead_code, reason = "fields only `Debug` reads")]

use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet, VecDeque};
use std::fmt;
use std::ops::{Range, RangeToInclusive};
use std::rc::Rc;
Expand Down Expand Up @@ -663,6 +664,66 @@ pub fn wrapped(data: &[u8], out: &mut Vec<u8>) {
put(out, &format!("{t} {t:?} {t:>9.2}"));
}

/// std's collections' `Debug`, which passes its options to each element: a deque from its
/// head however its buffer wraps, sets and maps in braces, nested, and pretty. A hash
/// collection holds at most one entry, since std leaves their order unspecified.
pub fn collections(data: &[u8], out: &mut Vec<u8>) {
let at = |i: usize| data.get(i).copied().unwrap_or(0);
// Each byte pushes or pops at either end, so the head wraps around the buffer.
let mut q: VecDeque<Option<u8>> = VecDeque::with_capacity(4);
for &b in data {
match b % 4 {
0 => q.push_back((b % 3 != 0).then_some(b)),
1 => q.push_front((b % 3 != 0).then_some(b)),
2 => {
q.pop_back();
}
_ => {
q.pop_front();
}
}
}
put(out, &format!("{q:?}|{q:#?}|{q:x?}|{q:>4?}"));
// Pushed at the front, the head wraps to the buffer's end, and popping the back past
// where it started leaves only what wrapped.
let mut wrapped = VecDeque::with_capacity(4);
wrapped.extend([Hex(1), Hex(2)]);
wrapped.push_front(Hex(u32::from(at(0)) * 0x1001));
wrapped.push_front(Hex(u32::from(at(1))));
wrapped.pop_back();
let mid = format!("{wrapped:?}");
wrapped.pop_back();
put(out, &format!("{mid}|{wrapped:?}|{wrapped:#?}|{wrapped:6?}"));
let empty = VecDeque::<u8>::new();
let units: VecDeque<()> = (0..at(2) % 3).map(|_| ()).collect();
put(out, &format!("{empty:?}|{empty:#?}|{units:?}"));
let nested: VecDeque<VecDeque<Pair>> = [VecDeque::new(), VecDeque::from([Pair(at(3), -1), Pair(2, 3)])].into();
put(out, &format!("{nested:?}|{nested:#?}"));

let sorted: BTreeSet<Option<u8>> = data.iter().map(|&b| (b % 3 != 0).then_some(b % 8)).collect();
put(out, &format!("{sorted:?}|{sorted:#?}|{sorted:02x?}"));
let mut map: BTreeMap<u8, VecDeque<Pair>> = BTreeMap::new();
for &b in data.iter().take(6) {
map.entry(b % 4).or_default().push_front(Pair(b, -i64::from(b)));
}
put(
out,
&format!(
"{map:?}|{map:#?}|{:?}|{:#?}",
BTreeMap::<u8, u8>::new(),
BTreeSet::<u8>::new()
),
);
let (mut one, mut set) = (HashMap::new(), HashSet::new());
if let Some(&b) = data.first() {
one.insert((b % 2 == 0).then_some(b), Hex(b.into()));
}
if let Some(&b) = data.get(1) {
set.insert(b);
}
put(out, &format!("{one:?}|{one:#?}|{one:>3?}|{set:?}|{set:#?}|{set:#04x?}"));
}

/// An error only a TypeScript caller prints, as moq's callers print its errors: nothing
/// translated formats it, so its `Display` and `Debug` come along as `printable`.
#[derive(Debug)]
Expand Down
1 change: 1 addition & 0 deletions ts/fixtures/lang/src/harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ fn cases() -> Vec<(&'static str, Case)> {
("arrays::lent", |_, data, out| arrays::lent(data, out)),
("floats::mul_adds", floats::mul_adds),
("singles::mul_adds", singles::mul_adds),
("fmt::collections", |_, data, out| fmt::collections(data, out)),
]
}

Expand Down
18 changes: 17 additions & 1 deletion ts/runtime/rt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1716,11 +1716,27 @@ export function fmtResult<T, E>(r: Result<T, E>, f: Formatter, ok: Debug<T>, err
return debugTupleFinish(debugTupleField(fmtDebugTuple(f, r.ok ? "Ok" : "Err"), field));
}

/** `Debug` of a slice, array, or `Vec`. */
/** `Debug` of a slice, array, `Vec`, `VecDeque`, or `BinaryHeap`. */
export function fmtList<T>(items: Iterable<T>, f: Formatter, debug: Debug<T>): FmtResult {
return debugListFinish(debugListEntries(fmtDebugList(f), items, debug));
}

/** `Debug` of a set: std's `DebugSet` is its `DebugList` in braces. */
export function fmtSet<T>(items: Iterable<T>, f: Formatter, debug: Debug<T>): FmtResult {
const b = debugListEntries({ fmt: f, result: f.out.writeStr("{"), hasFields: false }, items, debug);
if (b.result.ok) b.result = f.out.writeStr("}");
return b.result;
}

/** `Debug` of a map: a set of entries, each its key and value apart by `": "` in one indented field. */
export function fmtMap<K, V>(entries: Iterable<[K, V]>, f: Formatter, key: Debug<K>, value: Debug<V>): FmtResult {
return fmtSet(entries, f, ([k, v], f) => {
let r = key(k, f);
if (r.ok) r = f.out.writeStr(": ");
return r.ok ? value(v, f) : r;
});
}

/** `Debug` of a range: each bound present, written with the formatter's options, around `dots`, which none pads. */
function fmtBounds(f: Formatter, start: Fmt | undefined, dots: string, end: Fmt | undefined): FmtResult {
if (start !== undefined) {
Expand Down
16 changes: 16 additions & 0 deletions ts/src/lower/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,22 @@ pub fn std_impl<'tcx>(
let item = b.fmt_fn(tr, args.type_at(0), span);
rt("list", vec![value.member("d"), f, item])
}
// Each writes its items as its iterator reads them: a deque from its head.
(Std::VecDeque, Trait::Debug) => {
let item = b.fmt_fn(tr, args.type_at(0), span);
rt("list", vec![Expr::rt("dequeIter", vec![value]), f, item])
}
(std @ (Std::HashSet | Std::BTreeSet), Trait::Debug) => {
let item = b.fmt_fn(tr, args.type_at(0), span);
let keys = if std == Std::HashSet { "hashKeys" } else { "btreeKeys" };
rt("set", vec![Expr::rt(keys, vec![value]), f, item])
}
(std @ (Std::HashMap | Std::BTreeMap), Trait::Debug) => {
let key = b.fmt_fn(tr, args.type_at(0), span);
let val = b.fmt_fn(tr, args.type_at(1), span);
let entries = if std == Std::HashMap { "hashIter" } else { "btreeIter" };
rt("map", vec![Expr::rt(entries, vec![value]), f, key, val])
}
(Std::Option, Trait::Debug) => {
let some = b.fmt_fn(tr, args.type_at(0), span);
let none = b.t.none_arg(args.type_at(0));
Expand Down