diff --git a/quest/m3/README.md b/quest/m3/README.md index 6f53e6e56..955952119 100644 --- a/quest/m3/README.md +++ b/quest/m3/README.md @@ -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` 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 diff --git a/quest/m3/ts-deque-debug.md b/quest/m3/ts-deque-debug.md deleted file mode 100644 index b3d5ad6c6..000000000 --- a/quest/m3/ts-deque-debug.md +++ /dev/null @@ -1,15 +0,0 @@ -# [XS] A VecDeque's Debug - -## Goal - -[rust2-ts](/ts/README.md) translates `{:?}` of a `VecDeque`, writing the same text as -std's list, proven by a differential test against native Rust. - -## Plan - -Found by [#303](https://github.com/moq-dev/rust2/pull/303): `format!("{q:?}")` of a -`VecDeque<()>` refuses with `unsupported call to as Debug>::fmt`, for any -`T`. `fmt.rs` maps `Vec`'s and `BinaryHeap`'s `Debug` to `rt.list`; a deque needs its -elements in order from its head, as its iterator reads them. - -Public API: the translator's output. diff --git a/quest/m3/ts-iter-debug.md b/quest/m3/ts-iter-debug.md new file mode 100644 index 000000000..5b20ea10d --- /dev/null +++ b/quest/m3/ts-iter-debug.md @@ -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. diff --git a/quest/m3/ts-linked-list.md b/quest/m3/ts-linked-list.md new file mode 100644 index 000000000..64a50f47b --- /dev/null +++ b/quest/m3/ts-linked-list.md @@ -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. diff --git a/ts/README.md b/ts/README.md index 608626388..758dab7a9 100644 --- a/ts/README.md +++ b/ts/README.md @@ -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 diff --git a/ts/fixtures/lang/expected/fmt.ts b/ts/fixtures/lang/expected/fmt.ts index 13bc66062..b295b8789 100644 --- a/ts/fixtures/lang/expected/fmt.ts +++ b/ts/fixtures/lang/expected/fmt.ts @@ -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"; @@ -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.dequeNew() as rt.VecDeque; + 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 = rt.dequeNew() as rt.VecDeque; + 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.dequeNew() as rt.VecDeque; + const _91: rt.Iter = rt.iterMap(new rt.Range(0, rt.u8Rem(at(2), 3)), (_2: rt.u8): undefined => {}); + const units: rt.VecDeque = rt.dequeExtend(rt.dequeNew() as rt.VecDeque, _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 = rt.dequeNew() as rt.VecDeque; + const _116: Pair.Pair[] = [{ _0: at(3), _1: -1 }, { _0: 2, _1: 3 }]; + const _113: rt.VecDeque[] = [_114, rt.dequeExtend(rt.dequeNew() as rt.VecDeque, rt.iterSlice(_116), undefined, 16, true)]; + const part = rt.dequeExtend(rt.dequeNew() as rt.VecDeque>, rt.iterSlice(_113), undefined, 16, true); + const args10: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(rt.dequeIter(part), f, (value: rt.VecDeque, 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.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, _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.btreeNew(rt.cmp) as rt.BTreeMap>; + const iter2: rt.Iter = 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 => { + return rt.dequeNew() as rt.VecDeque; + }), { _0: b2, _1: rt.i64Neg(b2 as rt.i64) }); + } + const _176: rt.BTreeMap = rt.btreeNew(rt.cmp) as rt.BTreeMap; + const _178: rt.BTreeSet = rt.btreeNew(rt.cmp) as rt.BTreeSet; + const args14: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtMap(rt.btreeIter(map), f, rt.u8Debug, (value: rt.VecDeque, 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.HashSet] = [rt.hashNew(rt.hashing(rt.hashOption(rt.hash8), rt.same)) as rt.HashMap, rt.hashNew() as rt.HashSet]; + const one: rt.HashMap = _188[0]; + const set: rt.HashSet = _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. diff --git a/ts/fixtures/lang/expected/harness.ts b/ts/fixtures/lang/expected/harness.ts index 96a3147b1..d9039548f 100644 --- a/ts/fixtures/lang/expected/harness.ts +++ b/ts/fixtures/lang/expected/harness.ts @@ -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"; @@ -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. */ diff --git a/ts/fixtures/lang/src/fmt.rs b/ts/fixtures/lang/src/fmt.rs index e39f9d283..01c243b78 100644 --- a/ts/fixtures/lang/src/fmt.rs +++ b/ts/fixtures/lang/src/fmt.rs @@ -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; @@ -663,6 +664,66 @@ pub fn wrapped(data: &[u8], out: &mut Vec) { 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) { + 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> = 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::::new(); + let units: VecDeque<()> = (0..at(2) % 3).map(|_| ()).collect(); + put(out, &format!("{empty:?}|{empty:#?}|{units:?}")); + let nested: VecDeque> = [VecDeque::new(), VecDeque::from([Pair(at(3), -1), Pair(2, 3)])].into(); + put(out, &format!("{nested:?}|{nested:#?}")); + + let sorted: BTreeSet> = data.iter().map(|&b| (b % 3 != 0).then_some(b % 8)).collect(); + put(out, &format!("{sorted:?}|{sorted:#?}|{sorted:02x?}")); + let mut map: BTreeMap> = 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::::new(), + BTreeSet::::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)] diff --git a/ts/fixtures/lang/src/harness.rs b/ts/fixtures/lang/src/harness.rs index 92a1764db..212a0c6d0 100644 --- a/ts/fixtures/lang/src/harness.rs +++ b/ts/fixtures/lang/src/harness.rs @@ -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)), ] } diff --git a/ts/runtime/rt.ts b/ts/runtime/rt.ts index 434a76186..ad3c3caa5 100644 --- a/ts/runtime/rt.ts +++ b/ts/runtime/rt.ts @@ -1716,11 +1716,27 @@ export function fmtResult(r: Result, f: Formatter, ok: Debug, 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(items: Iterable, f: Formatter, debug: Debug): FmtResult { return debugListFinish(debugListEntries(fmtDebugList(f), items, debug)); } +/** `Debug` of a set: std's `DebugSet` is its `DebugList` in braces. */ +export function fmtSet(items: Iterable, f: Formatter, debug: Debug): 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(entries: Iterable<[K, V]>, f: Formatter, key: Debug, value: Debug): 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) { diff --git a/ts/src/lower/fmt.rs b/ts/src/lower/fmt.rs index cfbec2174..80aa15962 100644 --- a/ts/src/lower/fmt.rs +++ b/ts/src/lower/fmt.rs @@ -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));