diff --git a/quest/m3/README.md b/quest/m3/README.md index a9eabdf52..bc29eebb4 100644 --- a/quest/m3/README.md +++ b/quest/m3/README.md @@ -18,7 +18,6 @@ generic std gap is planned here even when moq never calls it. - [Unsafe code the translator can model](/quest/m3/ts-unsafe.md) - a dependency using only `unsafe` the translator can model translates from source - [The rest of Duration](/quest/m3/ts-duration.md) - compound assignment, float conversions, and `Sum` on a `Duration` translate - [Trait objects](/quest/m3/ts-dyn.md) - `dyn Trait` and `Box` translate, so a consumer neither rewrites nor binds them -- [The rest of format specs](/quest/m3/ts-fmt-specs.md) - precision, argument widths, `+`, and the other radixes format as `core::fmt` does - [Waiting: type-check in process with tsrs](/quest/m3/ts-tsrs.md) - rust2-ts checks bindings through tsrs instead of `tsc` once it is a stable library - [Fold matches across tests that aren't variant switches](/quest/m3/ts-fold-guards.md) - a match an `if` or guard decided drops its dead arms - [A crate's own comparison operators](/quest/m3/ts-partial-ord.md) - an overridden `lt`/`le`/`gt`/`ge` is called where std calls it diff --git a/quest/m3/ts-fmt-specs.md b/quest/m3/ts-fmt-specs.md deleted file mode 100644 index 0a281ebe7..000000000 --- a/quest/m3/ts-fmt-specs.md +++ /dev/null @@ -1,23 +0,0 @@ -# [M] The rest of format specs - -## Goal - -rust2-ts translates the format specs it refuses today, byte for byte as `core::fmt` -writes them, proven by differential tests against native Rust: a precision (`{:.3}`, -`{:.N?}`, `{:.*}`), widths and precisions from arguments (`{:1$}`, `{:w$}`), `+`, `{:b}`, -`{:o}`, `{:e}`, and `{:x?}`/`{:X?}`. - -## Plan - -Decided with the maintainer on 2026-10-27: rust2 aims to support all of std, so generic -gaps are planned without a moq consumer. Found by -[#125](https://github.com/kixelated/rust2/pull/125): `{:.N?}` is the usual way to print a -`Duration`. - -- The runtime ports `core::fmt` ([output](/ts/README.md)), so each spec belongs in that - port rather than a per-type special case. Each type's `Display` and `Debug` treat a - precision differently (floats round, strings truncate, `Duration` rounds its fraction), - so cover each. -- Update the README's list of refused specs. - -Public API: the translator's output. diff --git a/ts/README.md b/ts/README.md index dbdb7cf85..77830760e 100644 --- a/ts/README.md +++ b/ts/README.md @@ -122,8 +122,9 @@ translate, as do `Display` and `Debug` impls, derived and thiserror's included. runtime ports `core::fmt`, so the text matches native Rust's byte for byte. A placeholder becomes a function writing its value, and `fmt::Arguments` an array of literal pieces and such functions: `rt.fmtWriteFmt(f, ["code=", (f) => rt.u16Display(code, f)])`. A `&dyn -Debug` or `&dyn Display` is such a function too. Format specs take fill, alignment, -width, `#`, `0`, `x`, `X`, and `?`. `Debug` of a string or `char` escapes by the JS +Debug` or `&dyn Display` is such a function too. Format specs take every option but `{:p}`: +fill, alignment, `+`, `#`, `0`, `x?` and `X?`, a width and a precision, each also from an +argument, and `x`, `X`, `o`, `b`, `e`, and `E` for integers. `Debug` of a string or `char` escapes by the JS engine's Unicode tables, so a character newer than its Unicode version is escaped where Rust prints it. A caller prints a `printable` type as `to_string()` and `format!("{err:?}")` would: `rt.fmtToString((f) => DecodeError.fmt$Display(err, f))` and @@ -429,8 +430,8 @@ another type it borrows as through the crate's own `Borrow`, a `&mut` to a value copies that std makes, other than a map's, or hands a closure, as `iter_mut` and `and_modify` do, one into a `Result`'s payload passed on or kept, `Hasher::write` of bytes, the adaptors without a mapping in `src/lower/iter.rs` (such as `cycle`, `unzip`, and `partition`), an -own `impl Iterator` with `next_back`, `len`, or another provided method of its own, other -format specs (a precision, `+`, `{:b}`, `{:x?}`, and widths from arguments), writing to a +own `impl Iterator` with `next_back`, `len`, or another provided method of its own, +a pointer's address (`{:p}`), writing to a `String` with `write!`, a `str` pattern other than a `char`, a `&str`, or a predicate, a mutable `str` slice, a copy of a closure that changes what it captured, `mem::swap`, `replace`, or `take` of a reference's whole pointee, diff --git a/ts/fixtures/codec/expected/coding/decode.DecodeError.ts b/ts/fixtures/codec/expected/coding/decode.DecodeError.ts index 140a7aa7e..e58b5420a 100644 --- a/ts/fixtures/codec/expected/coding/decode.DecodeError.ts +++ b/ts/fixtures/codec/expected/coding/decode.DecodeError.ts @@ -16,7 +16,7 @@ export function fmt$Display(self: DecodeError, __formatter: rt.Formatter): rt.Re } if (self.tag === "InvalidMessage") { const arg = self._0; - const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.u64Display(arg, f)]; + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.u64Debug(arg, f)]; return rt.fmtWriteFmt(__formatter, ["invalid message: ", args2[0]]); } if (self.tag === "InvalidSubscribeLocation") { @@ -83,7 +83,7 @@ export function fmt$Debug(self: DecodeError, f: rt.Formatter): rt.Result rt.u64Display(self._0, f); + const _12: rt.Fmt = (f: rt.Formatter) => rt.u64Debug(self._0, f); return rt.debugTupleFinish(rt.debugTupleField(rt.fmtDebugTuple(f, _11), _12)); } if (self.tag === "InvalidSubscribeLocation") { @@ -104,9 +104,9 @@ export function fmt$Debug(self: DecodeError, f: rt.Formatter): rt.Result rt.usizeDisplay(self.size, f); + const _23: rt.Fmt = (f: rt.Formatter) => rt.usizeDebug(self.size, f); const _24: string = "max"; - const _25: rt.Fmt = (f: rt.Formatter) => rt.usizeDisplay(self.max, f); + const _25: rt.Fmt = (f: rt.Formatter) => rt.usizeDebug(self.max, f); return rt.debugStructFinish(rt.debugStructField(rt.debugStructField(rt.fmtDebugStruct(f, _21), _22, _23), _24, _25)); } if (self.tag === "ExpectedData") { diff --git a/ts/fixtures/codec/expected/lib.SessionError.ts b/ts/fixtures/codec/expected/lib.SessionError.ts index 350a6712a..06ff628f7 100644 --- a/ts/fixtures/codec/expected/lib.SessionError.ts +++ b/ts/fixtures/codec/expected/lib.SessionError.ts @@ -15,7 +15,7 @@ export function fmt$Debug(self: SessionError, f: rt.Formatter): rt.Result rt.u16Display(self._0, f); + const _7: rt.Fmt = (f: rt.Formatter) => rt.u16Debug(self._0, f); return rt.debugTupleFinish(rt.debugTupleField(rt.fmtDebugTuple(f, _6), _7)); } diff --git a/ts/fixtures/lang/expected/chunks.ts b/ts/fixtures/lang/expected/chunks.ts index 415e41dc2..edc869d4c 100644 --- a/ts/fixtures/lang/expected/chunks.ts +++ b/ts/fixtures/lang/expected/chunks.ts @@ -132,11 +132,11 @@ export function chunks(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { } rt.byteVecExtendFromSlice(out, chosen2); rt.byteVecPush(out, chosen2.data[chosen2.start + 1]); - const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(rt.byteSliceView(chosen2), f, rt.u8Display), (f: rt.Formatter) => rt.fmtList(rt.byteSliceView(lit), f, rt.u8Display)]; + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(rt.byteSliceView(chosen2), f, rt.u8Debug), (f: rt.Formatter) => rt.fmtList(rt.byteSliceView(lit), f, rt.u8Debug)]; rt.byteVecExtendFromSlice(out, rt.stringAsBytes(rt.fmtFormat([args2[0], " ", args2[1]]))); if (data.length >= 3) { const chunk: rt.ByteSlice = new rt.ByteSlice(data.data, data.start, 3); - const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(rt.byteSliceView(chunk), f, rt.u8Display), (f: rt.Formatter) => rt.fmtList(rt.byteSliceView(chunk), f, rt.u8Display)]; + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(rt.byteSliceView(chunk), f, rt.u8Debug), (f: rt.Formatter) => rt.fmtList(rt.byteSliceView(chunk), f, rt.u8Debug)]; rt.byteVecExtendFromSlice(out, rt.stringAsBytes(rt.fmtFormat([args4[0], " ", args4[1]]))); } } else if (_4 === 4) { diff --git a/ts/fixtures/lang/expected/cows.Named.ts b/ts/fixtures/lang/expected/cows.Named.ts index 330a217a7..c045e4490 100644 --- a/ts/fixtures/lang/expected/cows.Named.ts +++ b/ts/fixtures/lang/expected/cows.Named.ts @@ -11,7 +11,7 @@ export function fmt$Debug(self: Named, f: rt.Formatter): rt.Result rt.fmtStr(self.name, f); const _7: string = "id"; - const _8: rt.Fmt = (f: rt.Formatter) => rt.u8Display(self.id, f); + const _8: rt.Fmt = (f: rt.Formatter) => rt.u8Debug(self.id, f); return rt.debugStructFinish(rt.debugStructField(rt.debugStructField(rt.fmtDebugStruct(f, _3), _4, _5), _7, _8)); } diff --git a/ts/fixtures/lang/expected/durations.ts b/ts/fixtures/lang/expected/durations.ts index 518e0bd49..67fed57d5 100644 --- a/ts/fixtures/lang/expected/durations.ts +++ b/ts/fixtures/lang/expected/durations.ts @@ -139,34 +139,47 @@ export function durations(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): voi const _192: rt.Duration = rt.durationNew(rt.durationAsSecs(a), rt.durationSubsecNanos(a)); rt.byteVecPush(out, rt.hashContains(set, _192) ? 1 : 0); } else if (_24 === 8) { - const _212: rt.Duration | undefined = b; const c: rt.Duration = rt.durationNew(0, rt.durationSubsecNanos(b)); const d2: rt.Duration = rt.durationFromNanos(rt.u32Rem(n, 1000000) as rt.u64); - const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.durationDebug(a, f), (f: rt.Formatter) => rt.durationDebug(c, f), (f: rt.Formatter) => rt.durationDebug(d2, f), (f: rt.Formatter) => rt.fmtOption(_212, f, rt.durationDebug)]; + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.durationDebug(a, f), (f: rt.Formatter) => rt.durationDebug(c, f), (f: rt.Formatter) => rt.durationDebug(d2, f), (f: rt.Formatter) => rt.fmtOption(b, f, rt.durationDebug)]; put(out, rt.fmtFormat([args2[0], "|", args2[1], "|", args2[2], "|", rt.fmtSpec({ align: ">", width: 16 }, args2[1]), "|", rt.fmtSpec({ fill: "*", align: "^", width: 14 }, args2[2]), "|", rt.fmtSpec({ align: "<", width: 12 }, args2[1]), "|", rt.fmtSpec({ zero: true, width: 8 }, args2[0]), "|", args2[3]])); + const _234: rt.Duration | undefined = b; + const p: rt.usize = rt.u32Rem(n, 13) as rt.usize; + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.durationDebug(a, f), (f: rt.Formatter) => rt.durationDebug(c, f), (f: rt.Formatter) => rt.durationDebug(d2, f), rt.fmtCount(p), (f: rt.Formatter) => rt.fmtOption(_234, f, rt.durationDebug)]; + put(out, rt.fmtFormat([rt.fmtSpec({ precision: 0 }, args4[0]), "|", rt.fmtSpec({ precision: 3 }, args4[0]), "|", rt.fmtSpec({ precision: 1 }, args4[1]), "|", rt.fmtSpec({ precision: 12 }, args4[2]), "|", rt.fmtSpec({ plus: true }, args4[0]), "|", rt.fmtSpec({ plus: true, width: 12, precision: 2 }, args4[1]), "|", rt.fmtSpec({ align: "<", width: 10, precision: 1 }, args4[2]), "|", rt.fmtSpec({ precision: rt.fmtCountOf(args4[3]) }, args4[0]), "|", rt.fmtSpec({ precision: 1 }, args4[4])])); + const iter4: rt.Iter = rt.iterSlice([1500000000, 2500000000, 1250000, 1350000, 999500, 1999999999]); + while (true) { + const _250: rt.u64 | rt.Done = iter4.next(); + if (_250 === rt.DONE) { + break; + } + const part = rt.durationFromNanos(_250); + const args6: rt.Fmt[] = [(f: rt.Formatter) => rt.durationDebug(part, f)]; + put(out, rt.fmtFormat([rt.fmtSpec({ precision: 0 }, args6[0]), " ", rt.fmtSpec({ precision: 1 }, args6[0]), " ", rt.fmtSpec({ precision: 2 }, args6[0])])); + } } else { - const iter4: rt.Iter = rt.iterSlice([{ secs: 0, nanos: 0 }, { secs: { hi: 0xffffffff, lo: 0xffffffff } as rt.u64, nanos: 999999999 }, { secs: 0, nanos: 999 }]); + const iter5: rt.Iter = rt.iterSlice([{ secs: 0, nanos: 0 }, { secs: { hi: 0xffffffff, lo: 0xffffffff } as rt.u64, nanos: 999999999 }, { secs: 0, nanos: 999 }]); while (true) { - const _225: rt.Duration | rt.Done = iter4.next(); - if (_225 === rt.DONE) { + const _269: rt.Duration | rt.Done = iter5.next(); + if (_269 === rt.DONE) { break; } - putDuration(out, _225); + putDuration(out, _269); } putDuration(out, { secs: 1, nanos: 500000000 }); putDuration(out, { secs: 0, nanos: 0 }); putOpt(out, rt.durationCheckedAdd({ secs: { hi: 0xffffffff, lo: 0xffffffff } as rt.u64, nanos: 999999999 }, rt.durationFromNanos(1))); - const _237: rt.Duration | undefined = rt.thenSome(rt.durationCmp(b, { secs: 1, nanos: 500000000 }) === 1, b); - const w: Window.Window = { start: a, len: _237 }; - const _246: Window.Window = Window.default$Default(); - rt.byteVecPush(out, Window.eq$PartialEq(w, _246) ? 1 : 0); + const _281: rt.Duration | undefined = rt.thenSome(rt.durationCmp(b, { secs: 1, nanos: 500000000 }) === 1, b); + const w: Window.Window = { start: a, len: _281 }; + const _290: Window.Window = Window.default$Default(); + rt.byteVecPush(out, Window.eq$PartialEq(w, _290) ? 1 : 0); rt.byteVecPush(out, Window.cmp$Ord(w, { start: b, len: undefined }) < 0 ? 1 : 0); - const _258: Window.Window = copy$Window(Window.default$Default()); - const _256: rt.Iter = rt.iterSlice([copy$Window(w), copy$Window(w), _258]); - rt.byteVecPush(out, rt.hashLen(rt.hashExtendKeys(rt.hashNew(rt.hashing(Window.hash$Hash_DefaultHasher, Window.eq$PartialEq)) as rt.HashSet, _256)) & 0xff); - const _271: Window.Window = Window.default$Default(); - const args4: rt.Fmt[] = [(f: rt.Formatter) => Window.fmt$Debug(w, f), (f: rt.Formatter) => Window.fmt$Debug(_271, f)]; - put(out, rt.fmtFormat([args4[0], "|", rt.fmtSpec({ alternate: true }, args4[1])])); + const _302: Window.Window = copy$Window(Window.default$Default()); + const _300: rt.Iter = rt.iterSlice([copy$Window(w), copy$Window(w), _302]); + rt.byteVecPush(out, rt.hashLen(rt.hashExtendKeys(rt.hashNew(rt.hashing(Window.hash$Hash_DefaultHasher, Window.eq$PartialEq)) as rt.HashSet, _300)) & 0xff); + const _315: Window.Window = Window.default$Default(); + const args8: rt.Fmt[] = [(f: rt.Formatter) => Window.fmt$Debug(w, f), (f: rt.Formatter) => Window.fmt$Debug(_315, f)]; + put(out, rt.fmtFormat([args8[0], "|", rt.fmtSpec({ alternate: true }, args8[1])])); } } diff --git a/ts/fixtures/lang/expected/fmt.Fault.ts b/ts/fixtures/lang/expected/fmt.Fault.ts index 3b48094e1..feb40d318 100644 --- a/ts/fixtures/lang/expected/fmt.Fault.ts +++ b/ts/fixtures/lang/expected/fmt.Fault.ts @@ -10,15 +10,15 @@ export function fmt$Debug(self: Fault, f: rt.Formatter): rt.Result rt.u16Display(self._0, f); + const _7: rt.Fmt = (f: rt.Formatter) => rt.u16Debug(self._0, f); return rt.debugTupleFinish(rt.debugTupleField(rt.fmtDebugTuple(f, _6), _7)); } if (self.tag === "TooLarge") { const _11: string = "TooLarge"; const _12: string = "size"; - const _13: rt.Fmt = (f: rt.Formatter) => rt.usizeDisplay(self.size, f); + const _13: rt.Fmt = (f: rt.Formatter) => rt.usizeDebug(self.size, f); const _14: string = "max"; - const _15: rt.Fmt = (f: rt.Formatter) => rt.usizeDisplay(self.max, f); + const _15: rt.Fmt = (f: rt.Formatter) => rt.usizeDebug(self.max, f); return rt.debugStructFinish(rt.debugStructField(rt.debugStructField(rt.fmtDebugStruct(f, _11), _12, _13), _14, _15)); } const _18: string = "At"; diff --git a/ts/fixtures/lang/expected/fmt.Hex.ts b/ts/fixtures/lang/expected/fmt.Hex.ts index 83deb0834..20c9ede84 100644 --- a/ts/fixtures/lang/expected/fmt.Hex.ts +++ b/ts/fixtures/lang/expected/fmt.Hex.ts @@ -7,6 +7,24 @@ export interface Hex { _0: rt.u32; } +export function fmt$Binary(self: Hex, f: rt.Formatter): rt.Result { + return rt.u32Binary(self._0, f); +} + +export function fmt$Octal(self: Hex, f: rt.Formatter): rt.Result { + const arg = self._0; + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Octal(arg, f)]; + return rt.fmtWriteFmt(f, [args2[0]]); +} + +export function fmt$LowerExp(self: Hex, f: rt.Formatter): rt.Result { + return rt.u32LowerExp(self._0, f); +} + +export function fmt$UpperExp(self: Hex, f: rt.Formatter): rt.Result { + return rt.u32UpperExp(self._0, f); +} + export function fmt$Display(self: Hex, f: rt.Formatter): rt.Result { if (!rt.fmtAlternate(f)) { const arg2 = self._0; diff --git a/ts/fixtures/lang/expected/fmt.Kind.ts b/ts/fixtures/lang/expected/fmt.Kind.ts index 631f78ba8..eca521b67 100644 --- a/ts/fixtures/lang/expected/fmt.Kind.ts +++ b/ts/fixtures/lang/expected/fmt.Kind.ts @@ -14,14 +14,14 @@ export function fmt$Debug(self: Kind, f: rt.Formatter): rt.Result rt.u8Display(self._0, f); + const _9: rt.Fmt = (f: rt.Formatter) => rt.u8Debug(self._0, f); return rt.debugTupleFinish(rt.debugTupleField(rt.fmtDebugTuple(f, _8), _9)); } const _13: string = "Many"; const _14: string = "count"; - const _15: rt.Fmt = (f: rt.Formatter) => rt.u32Display(self.count, f); + const _15: rt.Fmt = (f: rt.Formatter) => rt.u32Debug(self.count, f); const _16: string = "items"; - const _17: rt.Fmt = (f: rt.Formatter) => rt.fmtList(rt.byteVecView(self.items), f, rt.u8Display); + const _17: rt.Fmt = (f: rt.Formatter) => rt.fmtList(rt.byteVecView(self.items), f, rt.u8Debug); return rt.debugStructFinish(rt.debugStructField(rt.debugStructField(rt.fmtDebugStruct(f, _13), _14, _15), _16, _17)); } diff --git a/ts/fixtures/lang/expected/fmt.Manual.ts b/ts/fixtures/lang/expected/fmt.Manual.ts index 4f2f5f506..8d22326a6 100644 --- a/ts/fixtures/lang/expected/fmt.Manual.ts +++ b/ts/fixtures/lang/expected/fmt.Manual.ts @@ -9,7 +9,7 @@ export interface Manual { } export function fmt$Debug(self: Manual, f: rt.Formatter): rt.Result { - return rt.debugStructFinishNonExhaustive(rt.debugStructField(rt.debugStructField(rt.fmtDebugStruct(f, "Manual"), "id", (f: rt.Formatter) => rt.u8Display(self.id, f)), "list", (f: rt.Formatter) => rt.fmtList(self.list, f, rt.u16Display))); + return rt.debugStructFinishNonExhaustive(rt.debugStructField(rt.debugStructField(rt.fmtDebugStruct(f, "Manual"), "id", (f: rt.Formatter) => rt.u8Debug(self.id, f)), "list", (f: rt.Formatter) => rt.fmtList(self.list, f, rt.u16Debug))); } //# sourceMappingURL=fmt.Manual.ts.map diff --git a/ts/fixtures/lang/expected/fmt.Nested.ts b/ts/fixtures/lang/expected/fmt.Nested.ts index 0affd4ea2..745b93ffb 100644 --- a/ts/fixtures/lang/expected/fmt.Nested.ts +++ b/ts/fixtures/lang/expected/fmt.Nested.ts @@ -8,7 +8,7 @@ import * as Shape from "./shapes.Shape.ts"; export function fmt$Debug(self: Nested, f: rt.Formatter): rt.Result { const names: string[] = ["name", "point", "shape", "tags", "pairs", "maybe", "none", "result", "list", "tuple", "single", "empty", "unit", "boxed"]; - const values: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtStr(self.name, f), (f: rt.Formatter) => Point.fmt$Debug(self.point, f), (f: rt.Formatter) => Shape.fmt$Debug(self.shape, f), (f: rt.Formatter) => rt.fmtList(rt.byteVecView(self.tags), f, rt.u8Display), (f: rt.Formatter) => rt.fmtList(self.pairs, f, (value: Pair.Pair, f: rt.Formatter) => Pair.fmt$Debug(value, f)), (f: rt.Formatter) => rt.fmtOption(self.maybe, f, (value: Pair.Pair, f: rt.Formatter) => Pair.fmt$Debug(value, f)), (f: rt.Formatter) => rt.fmtOption(self.none, f, rt.u8Display), (f: rt.Formatter) => rt.fmtResult(self.result, f, rt.u8Display, rt.fmtStr), (f: rt.Formatter) => rt.fmtList(self.list, f, rt.i16Display), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.u8Display(self.tuple[0], f), (f: rt.Formatter) => rt.fmtBool(self.tuple[1], f), (f: rt.Formatter) => rt.fmtStr(self.tuple[2], f)], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.u8Display(self.single[0], f)], f), (f: rt.Formatter) => rt.fmtList(rt.byteVecView(self.empty), f, rt.u8Display), (f: rt.Formatter) => rt.fmtUnit(self.unit, f), (f: rt.Formatter) => Kind.fmt$Debug(self.boxed, f)]; + const values: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtStr(self.name, f), (f: rt.Formatter) => Point.fmt$Debug(self.point, f), (f: rt.Formatter) => Shape.fmt$Debug(self.shape, f), (f: rt.Formatter) => rt.fmtList(rt.byteVecView(self.tags), f, rt.u8Debug), (f: rt.Formatter) => rt.fmtList(self.pairs, f, (value: Pair.Pair, f: rt.Formatter) => Pair.fmt$Debug(value, f)), (f: rt.Formatter) => rt.fmtOption(self.maybe, f, (value: Pair.Pair, f: rt.Formatter) => Pair.fmt$Debug(value, f)), (f: rt.Formatter) => rt.fmtOption(self.none, f, rt.u8Debug), (f: rt.Formatter) => rt.fmtResult(self.result, f, rt.u8Debug, rt.fmtStr), (f: rt.Formatter) => rt.fmtList(self.list, f, rt.i16Debug), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.u8Debug(self.tuple[0], f), (f: rt.Formatter) => rt.fmtBool(self.tuple[1], f), (f: rt.Formatter) => rt.fmtStr(self.tuple[2], f)], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.u8Debug(self.single[0], f)], f), (f: rt.Formatter) => rt.fmtList(rt.byteVecView(self.empty), f, rt.u8Debug), (f: rt.Formatter) => rt.fmtUnit(self.unit, f), (f: rt.Formatter) => Kind.fmt$Debug(self.boxed, f)]; return rt.fmtDebugStructFields(f, "Nested", names, values); } diff --git a/ts/fixtures/lang/expected/fmt.Noted.ts b/ts/fixtures/lang/expected/fmt.Noted.ts index 5d18c6a06..ab1d13cc0 100644 --- a/ts/fixtures/lang/expected/fmt.Noted.ts +++ b/ts/fixtures/lang/expected/fmt.Noted.ts @@ -12,7 +12,7 @@ export function fmt$Display(self: Noted, f: rt.Formatter): rt.Result rt.u8Display(_7, f), (f: rt.Formatter) => rt.fmtBool(_11, f), (f: rt.Formatter) => rt.fmtList(rt.byteVecView(log), f, rt.u8Display)]; + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.u8Display(_7, f), (f: rt.Formatter) => rt.fmtBool(_11, f), (f: rt.Formatter) => rt.fmtList(rt.byteVecView(log), f, rt.u8Debug)]; return rt.fmtWriteFmt(f, [args2[0], " ", args2[1], " ", args2[2]]); } diff --git a/ts/fixtures/lang/expected/fmt.Pair.ts b/ts/fixtures/lang/expected/fmt.Pair.ts index b95d20371..6291309d9 100644 --- a/ts/fixtures/lang/expected/fmt.Pair.ts +++ b/ts/fixtures/lang/expected/fmt.Pair.ts @@ -4,8 +4,8 @@ import * as rt from "./rt.ts"; export function fmt$Debug(self: Pair, f: rt.Formatter): rt.Result { const _3: string = "Pair"; - const _4: rt.Fmt = (f: rt.Formatter) => rt.u8Display(self._0, f); - const _6: rt.Fmt = (f: rt.Formatter) => rt.i64Display(self._1, f); + const _4: rt.Fmt = (f: rt.Formatter) => rt.u8Debug(self._0, f); + const _6: rt.Fmt = (f: rt.Formatter) => rt.i64Debug(self._1, f); return rt.debugTupleFinish(rt.debugTupleField(rt.debugTupleField(rt.fmtDebugTuple(f, _3), _4), _6)); } diff --git a/ts/fixtures/lang/expected/fmt.Six.ts b/ts/fixtures/lang/expected/fmt.Six.ts index ce8fbbd1c..18ef48d7c 100644 --- a/ts/fixtures/lang/expected/fmt.Six.ts +++ b/ts/fixtures/lang/expected/fmt.Six.ts @@ -3,7 +3,7 @@ import * as rt from "./rt.ts"; export function fmt$Debug(self: Six, f: rt.Formatter): rt.Result { - const values: rt.Fmt[] = [(f: rt.Formatter) => rt.u8Display(self._0, f), (f: rt.Formatter) => rt.u8Display(self._1, f), (f: rt.Formatter) => rt.u8Display(self._2, f), (f: rt.Formatter) => rt.u8Display(self._3, f), (f: rt.Formatter) => rt.u8Display(self._4, f), (f: rt.Formatter) => rt.u8Display(self._5, f)]; + const values: rt.Fmt[] = [(f: rt.Formatter) => rt.u8Debug(self._0, f), (f: rt.Formatter) => rt.u8Debug(self._1, f), (f: rt.Formatter) => rt.u8Debug(self._2, f), (f: rt.Formatter) => rt.u8Debug(self._3, f), (f: rt.Formatter) => rt.u8Debug(self._4, f), (f: rt.Formatter) => rt.u8Debug(self._5, f)]; return rt.fmtDebugTupleFields(f, "Six", values); } diff --git a/ts/fixtures/lang/expected/fmt.Tup.ts b/ts/fixtures/lang/expected/fmt.Tup.ts index bd7cf3500..3b967ed4d 100644 --- a/ts/fixtures/lang/expected/fmt.Tup.ts +++ b/ts/fixtures/lang/expected/fmt.Tup.ts @@ -9,9 +9,9 @@ export interface Tup { export function fmt$Debug(self: Tup, f: rt.Formatter): rt.Result { if (self._1 === undefined) { - return rt.debugTupleFinishNonExhaustive(rt.debugTupleField(rt.fmtDebugTuple(f, "Tup"), (f: rt.Formatter) => rt.u8Display(self._0, f))); + return rt.debugTupleFinishNonExhaustive(rt.debugTupleField(rt.fmtDebugTuple(f, "Tup"), (f: rt.Formatter) => rt.u8Debug(self._0, f))); } - return rt.debugTupleFinish(rt.debugTupleField(rt.debugTupleField(rt.fmtDebugTuple(f, "Tup"), (f: rt.Formatter) => rt.u8Display(self._0, f)), (f: rt.Formatter) => rt.fmtOption(self._1, f, rt.u8Display))); + return rt.debugTupleFinish(rt.debugTupleField(rt.debugTupleField(rt.fmtDebugTuple(f, "Tup"), (f: rt.Formatter) => rt.u8Debug(self._0, f)), (f: rt.Formatter) => rt.fmtOption(self._1, f, rt.u8Debug))); } //# sourceMappingURL=fmt.Tup.ts.map diff --git a/ts/fixtures/lang/expected/fmt.Wide.ts b/ts/fixtures/lang/expected/fmt.Wide.ts index 992edf388..818b6e810 100644 --- a/ts/fixtures/lang/expected/fmt.Wide.ts +++ b/ts/fixtures/lang/expected/fmt.Wide.ts @@ -4,7 +4,7 @@ import * as rt from "./rt.ts"; export function fmt$Debug(self: Wide, f: rt.Formatter): rt.Result { const names: string[] = ["a", "b", "c", "d", "e", "f"]; - const values: rt.Fmt[] = [(f: rt.Formatter) => rt.u8Display(self.a, f), (f: rt.Formatter) => rt.u16Display(self.b, f), (f: rt.Formatter) => rt.u32Display(self.c, f), (f: rt.Formatter) => rt.u64Display(self.d, f), (f: rt.Formatter) => rt.i8Display(self.e, f), (f: rt.Formatter) => rt.fmtBool(self.f, f)]; + const values: rt.Fmt[] = [(f: rt.Formatter) => rt.u8Debug(self.a, f), (f: rt.Formatter) => rt.u16Debug(self.b, f), (f: rt.Formatter) => rt.u32Debug(self.c, f), (f: rt.Formatter) => rt.u64Debug(self.d, f), (f: rt.Formatter) => rt.i8Debug(self.e, f), (f: rt.Formatter) => rt.fmtBool(self.f, f)]; return rt.fmtDebugStructFields(f, "Wide", names, values); } diff --git a/ts/fixtures/lang/expected/fmt.ts b/ts/fixtures/lang/expected/fmt.ts index 75e14999c..1563eb18a 100644 --- a/ts/fixtures/lang/expected/fmt.ts +++ b/ts/fixtures/lang/expected/fmt.ts @@ -1,7 +1,7 @@ // Generated by rust2-ts. Do not edit. import * as rt from "./rt.ts"; -import { unwrapOr$Option_u8 } from "./core/option.ts"; +import { unwrapOr$Option_char, unwrapOr$Option_u8 } from "./core/option.ts"; import * as Bare from "./fmt.Bare.ts"; import * as Braced from "./fmt.Braced.ts"; import * as Fails from "./fmt.Fails.ts"; @@ -33,96 +33,144 @@ export function ints(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { const n: rt.usize = rt.min(data.length, rt.byteSliceFrom(buf).length); rt.byteSliceCopyFromSlice(rt.byteSliceRange(rt.byteSliceFrom(buf), 0, n), rt.byteSliceRange(data, 0, n)); const v: rt.u8 = rt.u8FromBeBytes(buf); - const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.u8Display(v, f), (f: rt.Formatter) => rt.u8Display(v, f), (f: rt.Formatter) => rt.u8LowerHex(v, f), (f: rt.Formatter) => rt.u8UpperHex(v, f)]; + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.u8Display(v, f), (f: rt.Formatter) => rt.u8Debug(v, f), (f: rt.Formatter) => rt.u8LowerHex(v, f), (f: rt.Formatter) => rt.u8UpperHex(v, f)]; put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", rt.fmtSpec({ width: 5 }, args2[0]), "|", rt.fmtSpec({ align: "<", width: 5 }, args2[0]), "|", rt.fmtSpec({ align: "^", width: 7 }, args2[0]), "|", rt.fmtSpec({ align: ">", width: 4 }, args2[0]), "|", rt.fmtSpec({ fill: "*", align: "^", width: 9 }, args2[0]), "|", rt.fmtSpec({ fill: "é", align: ">", width: 6 }, args2[0]), "|", rt.fmtSpec({ zero: true, width: 5 }, args2[0]), "|", rt.fmtSpec({ align: "<", zero: true, width: 5 }, args2[0]), "|", args2[2], " ", args2[3], " ", rt.fmtSpec({ alternate: true }, args2[2]), " ", rt.fmtSpec({ alternate: true }, args2[3]), " ", rt.fmtSpec({ zero: true, width: 8 }, args2[2]), " ", rt.fmtSpec({ alternate: true, zero: true, width: 10 }, args2[2]), " ", rt.fmtSpec({ align: ">", width: 8 }, args2[2]), "|", rt.fmtSpec({ align: "<", alternate: true, width: 6 }, args2[3]), "|", rt.fmtSpec({ alternate: true }, args2[1]), " ", rt.fmtSpec({ width: 3 }, args2[1])])); + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.u8Display(v, f), (f: rt.Formatter) => rt.u8LowerHex(v, f), (f: rt.Formatter) => rt.u8Binary(v, f), (f: rt.Formatter) => rt.u8Octal(v, f), (f: rt.Formatter) => rt.u8Debug(v, f)]; + put(out, rt.fmtFormat([rt.fmtSpec({ plus: true }, args4[0]), " ", rt.fmtSpec({ plus: true, zero: true, width: 6 }, args4[0]), " ", rt.fmtSpec({ plus: true, alternate: true }, args4[1]), " ", args4[0], " ", rt.fmtSpec({ precision: 3 }, args4[0]), " ", rt.fmtSpec({ width: 8, precision: 2 }, args4[0]), "|", args4[2], " ", rt.fmtSpec({ alternate: true }, args4[2]), " ", rt.fmtSpec({ alternate: true, zero: true, width: 12 }, args4[2]), " ", args4[3], " ", rt.fmtSpec({ alternate: true }, args4[3]), " ", rt.fmtSpec({ plus: true }, args4[3]), "|", rt.fmtSpec({ debugHex: "x" }, args4[4]), " ", rt.fmtSpec({ alternate: true, debugHex: "X" }, args4[4]), " ", rt.fmtSpec({ zero: true, debugHex: "x", width: 6 }, args4[4]), " ", rt.fmtSpec({ plus: true }, args4[4])])); + const args6: rt.Fmt[] = [(f: rt.Formatter) => rt.u8LowerExp(v, f), (f: rt.Formatter) => rt.u8UpperExp(v, f)]; + put(out, rt.fmtFormat([args6[0], " ", args6[1], " ", rt.fmtSpec({ precision: 0 }, args6[0]), " ", rt.fmtSpec({ precision: 1 }, args6[0]), " ", rt.fmtSpec({ precision: 3 }, args6[0]), " ", rt.fmtSpec({ precision: 45 }, args6[1]), " ", rt.fmtSpec({ plus: true, precision: 2 }, args6[0]), " ", rt.fmtSpec({ zero: true, width: 12, precision: 1 }, args6[0]), " ", rt.fmtSpec({ align: "<", plus: true, width: 9 }, args6[0]), "| ", rt.fmtSpec({ alternate: true }, args6[0]), " ", rt.fmtSpec({ align: ">", width: 12, precision: 4 }, args6[1]), "|"])); put(out, rt.fmtToString((f: rt.Formatter) => rt.u8Display(v, f))); } else if (_4 === 1) { const buf2: Uint8Array = rt.bytes(2); const n2: rt.usize = rt.min(data.length, rt.byteSliceFrom(buf2).length); rt.byteSliceCopyFromSlice(rt.byteSliceRange(rt.byteSliceFrom(buf2), 0, n2), rt.byteSliceRange(data, 0, n2)); const v2: rt.u16 = rt.u16FromBeBytes(buf2); - const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.u16Display(v2, f), (f: rt.Formatter) => rt.u16Display(v2, f), (f: rt.Formatter) => rt.u16LowerHex(v2, f), (f: rt.Formatter) => rt.u16UpperHex(v2, f)]; - put(out, rt.fmtFormat([args4[0], " ", args4[1], " ", rt.fmtSpec({ width: 5 }, args4[0]), "|", rt.fmtSpec({ align: "<", width: 5 }, args4[0]), "|", rt.fmtSpec({ align: "^", width: 7 }, args4[0]), "|", rt.fmtSpec({ align: ">", width: 4 }, args4[0]), "|", rt.fmtSpec({ fill: "*", align: "^", width: 9 }, args4[0]), "|", rt.fmtSpec({ fill: "é", align: ">", width: 6 }, args4[0]), "|", rt.fmtSpec({ zero: true, width: 5 }, args4[0]), "|", rt.fmtSpec({ align: "<", zero: true, width: 5 }, args4[0]), "|", args4[2], " ", args4[3], " ", rt.fmtSpec({ alternate: true }, args4[2]), " ", rt.fmtSpec({ alternate: true }, args4[3]), " ", rt.fmtSpec({ zero: true, width: 8 }, args4[2]), " ", rt.fmtSpec({ alternate: true, zero: true, width: 10 }, args4[2]), " ", rt.fmtSpec({ align: ">", width: 8 }, args4[2]), "|", rt.fmtSpec({ align: "<", alternate: true, width: 6 }, args4[3]), "|", rt.fmtSpec({ alternate: true }, args4[1]), " ", rt.fmtSpec({ width: 3 }, args4[1])])); + const args8: rt.Fmt[] = [(f: rt.Formatter) => rt.u16Display(v2, f), (f: rt.Formatter) => rt.u16Debug(v2, f), (f: rt.Formatter) => rt.u16LowerHex(v2, f), (f: rt.Formatter) => rt.u16UpperHex(v2, f)]; + put(out, rt.fmtFormat([args8[0], " ", args8[1], " ", rt.fmtSpec({ width: 5 }, args8[0]), "|", rt.fmtSpec({ align: "<", width: 5 }, args8[0]), "|", rt.fmtSpec({ align: "^", width: 7 }, args8[0]), "|", rt.fmtSpec({ align: ">", width: 4 }, args8[0]), "|", rt.fmtSpec({ fill: "*", align: "^", width: 9 }, args8[0]), "|", rt.fmtSpec({ fill: "é", align: ">", width: 6 }, args8[0]), "|", rt.fmtSpec({ zero: true, width: 5 }, args8[0]), "|", rt.fmtSpec({ align: "<", zero: true, width: 5 }, args8[0]), "|", args8[2], " ", args8[3], " ", rt.fmtSpec({ alternate: true }, args8[2]), " ", rt.fmtSpec({ alternate: true }, args8[3]), " ", rt.fmtSpec({ zero: true, width: 8 }, args8[2]), " ", rt.fmtSpec({ alternate: true, zero: true, width: 10 }, args8[2]), " ", rt.fmtSpec({ align: ">", width: 8 }, args8[2]), "|", rt.fmtSpec({ align: "<", alternate: true, width: 6 }, args8[3]), "|", rt.fmtSpec({ alternate: true }, args8[1]), " ", rt.fmtSpec({ width: 3 }, args8[1])])); + const args10: rt.Fmt[] = [(f: rt.Formatter) => rt.u16Display(v2, f), (f: rt.Formatter) => rt.u16LowerHex(v2, f), (f: rt.Formatter) => rt.u16Binary(v2, f), (f: rt.Formatter) => rt.u16Octal(v2, f), (f: rt.Formatter) => rt.u16Debug(v2, f)]; + put(out, rt.fmtFormat([rt.fmtSpec({ plus: true }, args10[0]), " ", rt.fmtSpec({ plus: true, zero: true, width: 6 }, args10[0]), " ", rt.fmtSpec({ plus: true, alternate: true }, args10[1]), " ", args10[0], " ", rt.fmtSpec({ precision: 3 }, args10[0]), " ", rt.fmtSpec({ width: 8, precision: 2 }, args10[0]), "|", args10[2], " ", rt.fmtSpec({ alternate: true }, args10[2]), " ", rt.fmtSpec({ alternate: true, zero: true, width: 12 }, args10[2]), " ", args10[3], " ", rt.fmtSpec({ alternate: true }, args10[3]), " ", rt.fmtSpec({ plus: true }, args10[3]), "|", rt.fmtSpec({ debugHex: "x" }, args10[4]), " ", rt.fmtSpec({ alternate: true, debugHex: "X" }, args10[4]), " ", rt.fmtSpec({ zero: true, debugHex: "x", width: 6 }, args10[4]), " ", rt.fmtSpec({ plus: true }, args10[4])])); + const args12: rt.Fmt[] = [(f: rt.Formatter) => rt.u16LowerExp(v2, f), (f: rt.Formatter) => rt.u16UpperExp(v2, f)]; + put(out, rt.fmtFormat([args12[0], " ", args12[1], " ", rt.fmtSpec({ precision: 0 }, args12[0]), " ", rt.fmtSpec({ precision: 1 }, args12[0]), " ", rt.fmtSpec({ precision: 3 }, args12[0]), " ", rt.fmtSpec({ precision: 45 }, args12[1]), " ", rt.fmtSpec({ plus: true, precision: 2 }, args12[0]), " ", rt.fmtSpec({ zero: true, width: 12, precision: 1 }, args12[0]), " ", rt.fmtSpec({ align: "<", plus: true, width: 9 }, args12[0]), "| ", rt.fmtSpec({ alternate: true }, args12[0]), " ", rt.fmtSpec({ align: ">", width: 12, precision: 4 }, args12[1]), "|"])); put(out, rt.fmtToString((f: rt.Formatter) => rt.u16Display(v2, f))); } else if (_4 === 2) { const buf3: Uint8Array = rt.bytes(4); const n3: rt.usize = rt.min(data.length, rt.byteSliceFrom(buf3).length); rt.byteSliceCopyFromSlice(rt.byteSliceRange(rt.byteSliceFrom(buf3), 0, n3), rt.byteSliceRange(data, 0, n3)); const v3: rt.u32 = rt.u32FromBeBytes(buf3); - const args6: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(v3, f), (f: rt.Formatter) => rt.u32Display(v3, f), (f: rt.Formatter) => rt.u32LowerHex(v3, f), (f: rt.Formatter) => rt.u32UpperHex(v3, f)]; - put(out, rt.fmtFormat([args6[0], " ", args6[1], " ", rt.fmtSpec({ width: 5 }, args6[0]), "|", rt.fmtSpec({ align: "<", width: 5 }, args6[0]), "|", rt.fmtSpec({ align: "^", width: 7 }, args6[0]), "|", rt.fmtSpec({ align: ">", width: 4 }, args6[0]), "|", rt.fmtSpec({ fill: "*", align: "^", width: 9 }, args6[0]), "|", rt.fmtSpec({ fill: "é", align: ">", width: 6 }, args6[0]), "|", rt.fmtSpec({ zero: true, width: 5 }, args6[0]), "|", rt.fmtSpec({ align: "<", zero: true, width: 5 }, args6[0]), "|", args6[2], " ", args6[3], " ", rt.fmtSpec({ alternate: true }, args6[2]), " ", rt.fmtSpec({ alternate: true }, args6[3]), " ", rt.fmtSpec({ zero: true, width: 8 }, args6[2]), " ", rt.fmtSpec({ alternate: true, zero: true, width: 10 }, args6[2]), " ", rt.fmtSpec({ align: ">", width: 8 }, args6[2]), "|", rt.fmtSpec({ align: "<", alternate: true, width: 6 }, args6[3]), "|", rt.fmtSpec({ alternate: true }, args6[1]), " ", rt.fmtSpec({ width: 3 }, args6[1])])); + const args14: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(v3, f), (f: rt.Formatter) => rt.u32Debug(v3, f), (f: rt.Formatter) => rt.u32LowerHex(v3, f), (f: rt.Formatter) => rt.u32UpperHex(v3, f)]; + put(out, rt.fmtFormat([args14[0], " ", args14[1], " ", rt.fmtSpec({ width: 5 }, args14[0]), "|", rt.fmtSpec({ align: "<", width: 5 }, args14[0]), "|", rt.fmtSpec({ align: "^", width: 7 }, args14[0]), "|", rt.fmtSpec({ align: ">", width: 4 }, args14[0]), "|", rt.fmtSpec({ fill: "*", align: "^", width: 9 }, args14[0]), "|", rt.fmtSpec({ fill: "é", align: ">", width: 6 }, args14[0]), "|", rt.fmtSpec({ zero: true, width: 5 }, args14[0]), "|", rt.fmtSpec({ align: "<", zero: true, width: 5 }, args14[0]), "|", args14[2], " ", args14[3], " ", rt.fmtSpec({ alternate: true }, args14[2]), " ", rt.fmtSpec({ alternate: true }, args14[3]), " ", rt.fmtSpec({ zero: true, width: 8 }, args14[2]), " ", rt.fmtSpec({ alternate: true, zero: true, width: 10 }, args14[2]), " ", rt.fmtSpec({ align: ">", width: 8 }, args14[2]), "|", rt.fmtSpec({ align: "<", alternate: true, width: 6 }, args14[3]), "|", rt.fmtSpec({ alternate: true }, args14[1]), " ", rt.fmtSpec({ width: 3 }, args14[1])])); + const args16: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(v3, f), (f: rt.Formatter) => rt.u32LowerHex(v3, f), (f: rt.Formatter) => rt.u32Binary(v3, f), (f: rt.Formatter) => rt.u32Octal(v3, f), (f: rt.Formatter) => rt.u32Debug(v3, f)]; + put(out, rt.fmtFormat([rt.fmtSpec({ plus: true }, args16[0]), " ", rt.fmtSpec({ plus: true, zero: true, width: 6 }, args16[0]), " ", rt.fmtSpec({ plus: true, alternate: true }, args16[1]), " ", args16[0], " ", rt.fmtSpec({ precision: 3 }, args16[0]), " ", rt.fmtSpec({ width: 8, precision: 2 }, args16[0]), "|", args16[2], " ", rt.fmtSpec({ alternate: true }, args16[2]), " ", rt.fmtSpec({ alternate: true, zero: true, width: 12 }, args16[2]), " ", args16[3], " ", rt.fmtSpec({ alternate: true }, args16[3]), " ", rt.fmtSpec({ plus: true }, args16[3]), "|", rt.fmtSpec({ debugHex: "x" }, args16[4]), " ", rt.fmtSpec({ alternate: true, debugHex: "X" }, args16[4]), " ", rt.fmtSpec({ zero: true, debugHex: "x", width: 6 }, args16[4]), " ", rt.fmtSpec({ plus: true }, args16[4])])); + const args18: rt.Fmt[] = [(f: rt.Formatter) => rt.u32LowerExp(v3, f), (f: rt.Formatter) => rt.u32UpperExp(v3, f)]; + put(out, rt.fmtFormat([args18[0], " ", args18[1], " ", rt.fmtSpec({ precision: 0 }, args18[0]), " ", rt.fmtSpec({ precision: 1 }, args18[0]), " ", rt.fmtSpec({ precision: 3 }, args18[0]), " ", rt.fmtSpec({ precision: 45 }, args18[1]), " ", rt.fmtSpec({ plus: true, precision: 2 }, args18[0]), " ", rt.fmtSpec({ zero: true, width: 12, precision: 1 }, args18[0]), " ", rt.fmtSpec({ align: "<", plus: true, width: 9 }, args18[0]), "| ", rt.fmtSpec({ alternate: true }, args18[0]), " ", rt.fmtSpec({ align: ">", width: 12, precision: 4 }, args18[1]), "|"])); put(out, rt.fmtToString((f: rt.Formatter) => rt.u32Display(v3, f))); } else if (_4 === 3) { const buf4: Uint8Array = rt.bytes(8); const n4: rt.usize = rt.min(data.length, rt.byteSliceFrom(buf4).length); rt.byteSliceCopyFromSlice(rt.byteSliceRange(rt.byteSliceFrom(buf4), 0, n4), rt.byteSliceRange(data, 0, n4)); const v4: rt.u64 = rt.u64FromBeBytes(buf4); - const args8: rt.Fmt[] = [(f: rt.Formatter) => rt.u64Display(v4, f), (f: rt.Formatter) => rt.u64Display(v4, f), (f: rt.Formatter) => rt.u64LowerHex(v4, f), (f: rt.Formatter) => rt.u64UpperHex(v4, f)]; - put(out, rt.fmtFormat([args8[0], " ", args8[1], " ", rt.fmtSpec({ width: 5 }, args8[0]), "|", rt.fmtSpec({ align: "<", width: 5 }, args8[0]), "|", rt.fmtSpec({ align: "^", width: 7 }, args8[0]), "|", rt.fmtSpec({ align: ">", width: 4 }, args8[0]), "|", rt.fmtSpec({ fill: "*", align: "^", width: 9 }, args8[0]), "|", rt.fmtSpec({ fill: "é", align: ">", width: 6 }, args8[0]), "|", rt.fmtSpec({ zero: true, width: 5 }, args8[0]), "|", rt.fmtSpec({ align: "<", zero: true, width: 5 }, args8[0]), "|", args8[2], " ", args8[3], " ", rt.fmtSpec({ alternate: true }, args8[2]), " ", rt.fmtSpec({ alternate: true }, args8[3]), " ", rt.fmtSpec({ zero: true, width: 8 }, args8[2]), " ", rt.fmtSpec({ alternate: true, zero: true, width: 10 }, args8[2]), " ", rt.fmtSpec({ align: ">", width: 8 }, args8[2]), "|", rt.fmtSpec({ align: "<", alternate: true, width: 6 }, args8[3]), "|", rt.fmtSpec({ alternate: true }, args8[1]), " ", rt.fmtSpec({ width: 3 }, args8[1])])); + const args20: rt.Fmt[] = [(f: rt.Formatter) => rt.u64Display(v4, f), (f: rt.Formatter) => rt.u64Debug(v4, f), (f: rt.Formatter) => rt.u64LowerHex(v4, f), (f: rt.Formatter) => rt.u64UpperHex(v4, f)]; + put(out, rt.fmtFormat([args20[0], " ", args20[1], " ", rt.fmtSpec({ width: 5 }, args20[0]), "|", rt.fmtSpec({ align: "<", width: 5 }, args20[0]), "|", rt.fmtSpec({ align: "^", width: 7 }, args20[0]), "|", rt.fmtSpec({ align: ">", width: 4 }, args20[0]), "|", rt.fmtSpec({ fill: "*", align: "^", width: 9 }, args20[0]), "|", rt.fmtSpec({ fill: "é", align: ">", width: 6 }, args20[0]), "|", rt.fmtSpec({ zero: true, width: 5 }, args20[0]), "|", rt.fmtSpec({ align: "<", zero: true, width: 5 }, args20[0]), "|", args20[2], " ", args20[3], " ", rt.fmtSpec({ alternate: true }, args20[2]), " ", rt.fmtSpec({ alternate: true }, args20[3]), " ", rt.fmtSpec({ zero: true, width: 8 }, args20[2]), " ", rt.fmtSpec({ alternate: true, zero: true, width: 10 }, args20[2]), " ", rt.fmtSpec({ align: ">", width: 8 }, args20[2]), "|", rt.fmtSpec({ align: "<", alternate: true, width: 6 }, args20[3]), "|", rt.fmtSpec({ alternate: true }, args20[1]), " ", rt.fmtSpec({ width: 3 }, args20[1])])); + const args22: rt.Fmt[] = [(f: rt.Formatter) => rt.u64Display(v4, f), (f: rt.Formatter) => rt.u64LowerHex(v4, f), (f: rt.Formatter) => rt.u64Binary(v4, f), (f: rt.Formatter) => rt.u64Octal(v4, f), (f: rt.Formatter) => rt.u64Debug(v4, f)]; + put(out, rt.fmtFormat([rt.fmtSpec({ plus: true }, args22[0]), " ", rt.fmtSpec({ plus: true, zero: true, width: 6 }, args22[0]), " ", rt.fmtSpec({ plus: true, alternate: true }, args22[1]), " ", args22[0], " ", rt.fmtSpec({ precision: 3 }, args22[0]), " ", rt.fmtSpec({ width: 8, precision: 2 }, args22[0]), "|", args22[2], " ", rt.fmtSpec({ alternate: true }, args22[2]), " ", rt.fmtSpec({ alternate: true, zero: true, width: 12 }, args22[2]), " ", args22[3], " ", rt.fmtSpec({ alternate: true }, args22[3]), " ", rt.fmtSpec({ plus: true }, args22[3]), "|", rt.fmtSpec({ debugHex: "x" }, args22[4]), " ", rt.fmtSpec({ alternate: true, debugHex: "X" }, args22[4]), " ", rt.fmtSpec({ zero: true, debugHex: "x", width: 6 }, args22[4]), " ", rt.fmtSpec({ plus: true }, args22[4])])); + const args24: rt.Fmt[] = [(f: rt.Formatter) => rt.u64LowerExp(v4, f), (f: rt.Formatter) => rt.u64UpperExp(v4, f)]; + put(out, rt.fmtFormat([args24[0], " ", args24[1], " ", rt.fmtSpec({ precision: 0 }, args24[0]), " ", rt.fmtSpec({ precision: 1 }, args24[0]), " ", rt.fmtSpec({ precision: 3 }, args24[0]), " ", rt.fmtSpec({ precision: 45 }, args24[1]), " ", rt.fmtSpec({ plus: true, precision: 2 }, args24[0]), " ", rt.fmtSpec({ zero: true, width: 12, precision: 1 }, args24[0]), " ", rt.fmtSpec({ align: "<", plus: true, width: 9 }, args24[0]), "| ", rt.fmtSpec({ alternate: true }, args24[0]), " ", rt.fmtSpec({ align: ">", width: 12, precision: 4 }, args24[1]), "|"])); put(out, rt.fmtToString((f: rt.Formatter) => rt.u64Display(v4, f))); } else if (_4 === 4) { const buf5: Uint8Array = rt.bytes(16); const n5: rt.usize = rt.min(data.length, rt.byteSliceFrom(buf5).length); rt.byteSliceCopyFromSlice(rt.byteSliceRange(rt.byteSliceFrom(buf5), 0, n5), rt.byteSliceRange(data, 0, n5)); const v5: rt.u128 = rt.u128FromBeBytes(buf5); - const args10: rt.Fmt[] = [(f: rt.Formatter) => rt.u128Display(v5, f), (f: rt.Formatter) => rt.u128Display(v5, f), (f: rt.Formatter) => rt.u128LowerHex(v5, f), (f: rt.Formatter) => rt.u128UpperHex(v5, f)]; - put(out, rt.fmtFormat([args10[0], " ", args10[1], " ", rt.fmtSpec({ width: 5 }, args10[0]), "|", rt.fmtSpec({ align: "<", width: 5 }, args10[0]), "|", rt.fmtSpec({ align: "^", width: 7 }, args10[0]), "|", rt.fmtSpec({ align: ">", width: 4 }, args10[0]), "|", rt.fmtSpec({ fill: "*", align: "^", width: 9 }, args10[0]), "|", rt.fmtSpec({ fill: "é", align: ">", width: 6 }, args10[0]), "|", rt.fmtSpec({ zero: true, width: 5 }, args10[0]), "|", rt.fmtSpec({ align: "<", zero: true, width: 5 }, args10[0]), "|", args10[2], " ", args10[3], " ", rt.fmtSpec({ alternate: true }, args10[2]), " ", rt.fmtSpec({ alternate: true }, args10[3]), " ", rt.fmtSpec({ zero: true, width: 8 }, args10[2]), " ", rt.fmtSpec({ alternate: true, zero: true, width: 10 }, args10[2]), " ", rt.fmtSpec({ align: ">", width: 8 }, args10[2]), "|", rt.fmtSpec({ align: "<", alternate: true, width: 6 }, args10[3]), "|", rt.fmtSpec({ alternate: true }, args10[1]), " ", rt.fmtSpec({ width: 3 }, args10[1])])); + const args26: rt.Fmt[] = [(f: rt.Formatter) => rt.u128Display(v5, f), (f: rt.Formatter) => rt.u128Debug(v5, f), (f: rt.Formatter) => rt.u128LowerHex(v5, f), (f: rt.Formatter) => rt.u128UpperHex(v5, f)]; + put(out, rt.fmtFormat([args26[0], " ", args26[1], " ", rt.fmtSpec({ width: 5 }, args26[0]), "|", rt.fmtSpec({ align: "<", width: 5 }, args26[0]), "|", rt.fmtSpec({ align: "^", width: 7 }, args26[0]), "|", rt.fmtSpec({ align: ">", width: 4 }, args26[0]), "|", rt.fmtSpec({ fill: "*", align: "^", width: 9 }, args26[0]), "|", rt.fmtSpec({ fill: "é", align: ">", width: 6 }, args26[0]), "|", rt.fmtSpec({ zero: true, width: 5 }, args26[0]), "|", rt.fmtSpec({ align: "<", zero: true, width: 5 }, args26[0]), "|", args26[2], " ", args26[3], " ", rt.fmtSpec({ alternate: true }, args26[2]), " ", rt.fmtSpec({ alternate: true }, args26[3]), " ", rt.fmtSpec({ zero: true, width: 8 }, args26[2]), " ", rt.fmtSpec({ alternate: true, zero: true, width: 10 }, args26[2]), " ", rt.fmtSpec({ align: ">", width: 8 }, args26[2]), "|", rt.fmtSpec({ align: "<", alternate: true, width: 6 }, args26[3]), "|", rt.fmtSpec({ alternate: true }, args26[1]), " ", rt.fmtSpec({ width: 3 }, args26[1])])); + const args28: rt.Fmt[] = [(f: rt.Formatter) => rt.u128Display(v5, f), (f: rt.Formatter) => rt.u128LowerHex(v5, f), (f: rt.Formatter) => rt.u128Binary(v5, f), (f: rt.Formatter) => rt.u128Octal(v5, f), (f: rt.Formatter) => rt.u128Debug(v5, f)]; + put(out, rt.fmtFormat([rt.fmtSpec({ plus: true }, args28[0]), " ", rt.fmtSpec({ plus: true, zero: true, width: 6 }, args28[0]), " ", rt.fmtSpec({ plus: true, alternate: true }, args28[1]), " ", args28[0], " ", rt.fmtSpec({ precision: 3 }, args28[0]), " ", rt.fmtSpec({ width: 8, precision: 2 }, args28[0]), "|", args28[2], " ", rt.fmtSpec({ alternate: true }, args28[2]), " ", rt.fmtSpec({ alternate: true, zero: true, width: 12 }, args28[2]), " ", args28[3], " ", rt.fmtSpec({ alternate: true }, args28[3]), " ", rt.fmtSpec({ plus: true }, args28[3]), "|", rt.fmtSpec({ debugHex: "x" }, args28[4]), " ", rt.fmtSpec({ alternate: true, debugHex: "X" }, args28[4]), " ", rt.fmtSpec({ zero: true, debugHex: "x", width: 6 }, args28[4]), " ", rt.fmtSpec({ plus: true }, args28[4])])); + const args30: rt.Fmt[] = [(f: rt.Formatter) => rt.u128LowerExp(v5, f), (f: rt.Formatter) => rt.u128UpperExp(v5, f)]; + put(out, rt.fmtFormat([args30[0], " ", args30[1], " ", rt.fmtSpec({ precision: 0 }, args30[0]), " ", rt.fmtSpec({ precision: 1 }, args30[0]), " ", rt.fmtSpec({ precision: 3 }, args30[0]), " ", rt.fmtSpec({ precision: 45 }, args30[1]), " ", rt.fmtSpec({ plus: true, precision: 2 }, args30[0]), " ", rt.fmtSpec({ zero: true, width: 12, precision: 1 }, args30[0]), " ", rt.fmtSpec({ align: "<", plus: true, width: 9 }, args30[0]), "| ", rt.fmtSpec({ alternate: true }, args30[0]), " ", rt.fmtSpec({ align: ">", width: 12, precision: 4 }, args30[1]), "|"])); put(out, rt.fmtToString((f: rt.Formatter) => rt.u128Display(v5, f))); } else if (_4 === 5) { const buf6: Uint8Array = rt.bytes(4); const n6: rt.usize = rt.min(data.length, rt.byteSliceFrom(buf6).length); rt.byteSliceCopyFromSlice(rt.byteSliceRange(rt.byteSliceFrom(buf6), 0, n6), rt.byteSliceRange(data, 0, n6)); const v6: rt.usize = rt.usizeFromBeBytes(buf6); - const args12: rt.Fmt[] = [(f: rt.Formatter) => rt.usizeDisplay(v6, f), (f: rt.Formatter) => rt.usizeDisplay(v6, f), (f: rt.Formatter) => rt.usizeLowerHex(v6, f), (f: rt.Formatter) => rt.usizeUpperHex(v6, f)]; - put(out, rt.fmtFormat([args12[0], " ", args12[1], " ", rt.fmtSpec({ width: 5 }, args12[0]), "|", rt.fmtSpec({ align: "<", width: 5 }, args12[0]), "|", rt.fmtSpec({ align: "^", width: 7 }, args12[0]), "|", rt.fmtSpec({ align: ">", width: 4 }, args12[0]), "|", rt.fmtSpec({ fill: "*", align: "^", width: 9 }, args12[0]), "|", rt.fmtSpec({ fill: "é", align: ">", width: 6 }, args12[0]), "|", rt.fmtSpec({ zero: true, width: 5 }, args12[0]), "|", rt.fmtSpec({ align: "<", zero: true, width: 5 }, args12[0]), "|", args12[2], " ", args12[3], " ", rt.fmtSpec({ alternate: true }, args12[2]), " ", rt.fmtSpec({ alternate: true }, args12[3]), " ", rt.fmtSpec({ zero: true, width: 8 }, args12[2]), " ", rt.fmtSpec({ alternate: true, zero: true, width: 10 }, args12[2]), " ", rt.fmtSpec({ align: ">", width: 8 }, args12[2]), "|", rt.fmtSpec({ align: "<", alternate: true, width: 6 }, args12[3]), "|", rt.fmtSpec({ alternate: true }, args12[1]), " ", rt.fmtSpec({ width: 3 }, args12[1])])); + const args32: rt.Fmt[] = [(f: rt.Formatter) => rt.usizeDisplay(v6, f), (f: rt.Formatter) => rt.usizeDebug(v6, f), (f: rt.Formatter) => rt.usizeLowerHex(v6, f), (f: rt.Formatter) => rt.usizeUpperHex(v6, f)]; + put(out, rt.fmtFormat([args32[0], " ", args32[1], " ", rt.fmtSpec({ width: 5 }, args32[0]), "|", rt.fmtSpec({ align: "<", width: 5 }, args32[0]), "|", rt.fmtSpec({ align: "^", width: 7 }, args32[0]), "|", rt.fmtSpec({ align: ">", width: 4 }, args32[0]), "|", rt.fmtSpec({ fill: "*", align: "^", width: 9 }, args32[0]), "|", rt.fmtSpec({ fill: "é", align: ">", width: 6 }, args32[0]), "|", rt.fmtSpec({ zero: true, width: 5 }, args32[0]), "|", rt.fmtSpec({ align: "<", zero: true, width: 5 }, args32[0]), "|", args32[2], " ", args32[3], " ", rt.fmtSpec({ alternate: true }, args32[2]), " ", rt.fmtSpec({ alternate: true }, args32[3]), " ", rt.fmtSpec({ zero: true, width: 8 }, args32[2]), " ", rt.fmtSpec({ alternate: true, zero: true, width: 10 }, args32[2]), " ", rt.fmtSpec({ align: ">", width: 8 }, args32[2]), "|", rt.fmtSpec({ align: "<", alternate: true, width: 6 }, args32[3]), "|", rt.fmtSpec({ alternate: true }, args32[1]), " ", rt.fmtSpec({ width: 3 }, args32[1])])); + const args34: rt.Fmt[] = [(f: rt.Formatter) => rt.usizeDisplay(v6, f), (f: rt.Formatter) => rt.usizeLowerHex(v6, f), (f: rt.Formatter) => rt.usizeBinary(v6, f), (f: rt.Formatter) => rt.usizeOctal(v6, f), (f: rt.Formatter) => rt.usizeDebug(v6, f)]; + put(out, rt.fmtFormat([rt.fmtSpec({ plus: true }, args34[0]), " ", rt.fmtSpec({ plus: true, zero: true, width: 6 }, args34[0]), " ", rt.fmtSpec({ plus: true, alternate: true }, args34[1]), " ", args34[0], " ", rt.fmtSpec({ precision: 3 }, args34[0]), " ", rt.fmtSpec({ width: 8, precision: 2 }, args34[0]), "|", args34[2], " ", rt.fmtSpec({ alternate: true }, args34[2]), " ", rt.fmtSpec({ alternate: true, zero: true, width: 12 }, args34[2]), " ", args34[3], " ", rt.fmtSpec({ alternate: true }, args34[3]), " ", rt.fmtSpec({ plus: true }, args34[3]), "|", rt.fmtSpec({ debugHex: "x" }, args34[4]), " ", rt.fmtSpec({ alternate: true, debugHex: "X" }, args34[4]), " ", rt.fmtSpec({ zero: true, debugHex: "x", width: 6 }, args34[4]), " ", rt.fmtSpec({ plus: true }, args34[4])])); + const args36: rt.Fmt[] = [(f: rt.Formatter) => rt.usizeLowerExp(v6, f), (f: rt.Formatter) => rt.usizeUpperExp(v6, f)]; + put(out, rt.fmtFormat([args36[0], " ", args36[1], " ", rt.fmtSpec({ precision: 0 }, args36[0]), " ", rt.fmtSpec({ precision: 1 }, args36[0]), " ", rt.fmtSpec({ precision: 3 }, args36[0]), " ", rt.fmtSpec({ precision: 45 }, args36[1]), " ", rt.fmtSpec({ plus: true, precision: 2 }, args36[0]), " ", rt.fmtSpec({ zero: true, width: 12, precision: 1 }, args36[0]), " ", rt.fmtSpec({ align: "<", plus: true, width: 9 }, args36[0]), "| ", rt.fmtSpec({ alternate: true }, args36[0]), " ", rt.fmtSpec({ align: ">", width: 12, precision: 4 }, args36[1]), "|"])); put(out, rt.fmtToString((f: rt.Formatter) => rt.usizeDisplay(v6, f))); } else if (_4 === 6) { const buf7: Uint8Array = Uint8Array.of(0); const n7: rt.usize = rt.min(data.length, rt.byteSliceFrom(buf7).length); rt.byteSliceCopyFromSlice(rt.byteSliceRange(rt.byteSliceFrom(buf7), 0, n7), rt.byteSliceRange(data, 0, n7)); const v7: rt.i8 = rt.i8FromBeBytes(buf7); - const args14: rt.Fmt[] = [(f: rt.Formatter) => rt.i8Display(v7, f), (f: rt.Formatter) => rt.i8Display(v7, f), (f: rt.Formatter) => rt.i8LowerHex(v7, f), (f: rt.Formatter) => rt.i8UpperHex(v7, f)]; - put(out, rt.fmtFormat([args14[0], " ", args14[1], " ", rt.fmtSpec({ width: 5 }, args14[0]), "|", rt.fmtSpec({ align: "<", width: 5 }, args14[0]), "|", rt.fmtSpec({ align: "^", width: 7 }, args14[0]), "|", rt.fmtSpec({ align: ">", width: 4 }, args14[0]), "|", rt.fmtSpec({ fill: "*", align: "^", width: 9 }, args14[0]), "|", rt.fmtSpec({ fill: "é", align: ">", width: 6 }, args14[0]), "|", rt.fmtSpec({ zero: true, width: 5 }, args14[0]), "|", rt.fmtSpec({ align: "<", zero: true, width: 5 }, args14[0]), "|", args14[2], " ", args14[3], " ", rt.fmtSpec({ alternate: true }, args14[2]), " ", rt.fmtSpec({ alternate: true }, args14[3]), " ", rt.fmtSpec({ zero: true, width: 8 }, args14[2]), " ", rt.fmtSpec({ alternate: true, zero: true, width: 10 }, args14[2]), " ", rt.fmtSpec({ align: ">", width: 8 }, args14[2]), "|", rt.fmtSpec({ align: "<", alternate: true, width: 6 }, args14[3]), "|", rt.fmtSpec({ alternate: true }, args14[1]), " ", rt.fmtSpec({ width: 3 }, args14[1])])); + const args38: rt.Fmt[] = [(f: rt.Formatter) => rt.i8Display(v7, f), (f: rt.Formatter) => rt.i8Debug(v7, f), (f: rt.Formatter) => rt.i8LowerHex(v7, f), (f: rt.Formatter) => rt.i8UpperHex(v7, f)]; + put(out, rt.fmtFormat([args38[0], " ", args38[1], " ", rt.fmtSpec({ width: 5 }, args38[0]), "|", rt.fmtSpec({ align: "<", width: 5 }, args38[0]), "|", rt.fmtSpec({ align: "^", width: 7 }, args38[0]), "|", rt.fmtSpec({ align: ">", width: 4 }, args38[0]), "|", rt.fmtSpec({ fill: "*", align: "^", width: 9 }, args38[0]), "|", rt.fmtSpec({ fill: "é", align: ">", width: 6 }, args38[0]), "|", rt.fmtSpec({ zero: true, width: 5 }, args38[0]), "|", rt.fmtSpec({ align: "<", zero: true, width: 5 }, args38[0]), "|", args38[2], " ", args38[3], " ", rt.fmtSpec({ alternate: true }, args38[2]), " ", rt.fmtSpec({ alternate: true }, args38[3]), " ", rt.fmtSpec({ zero: true, width: 8 }, args38[2]), " ", rt.fmtSpec({ alternate: true, zero: true, width: 10 }, args38[2]), " ", rt.fmtSpec({ align: ">", width: 8 }, args38[2]), "|", rt.fmtSpec({ align: "<", alternate: true, width: 6 }, args38[3]), "|", rt.fmtSpec({ alternate: true }, args38[1]), " ", rt.fmtSpec({ width: 3 }, args38[1])])); + const args40: rt.Fmt[] = [(f: rt.Formatter) => rt.i8Display(v7, f), (f: rt.Formatter) => rt.i8LowerHex(v7, f), (f: rt.Formatter) => rt.i8Binary(v7, f), (f: rt.Formatter) => rt.i8Octal(v7, f), (f: rt.Formatter) => rt.i8Debug(v7, f)]; + put(out, rt.fmtFormat([rt.fmtSpec({ plus: true }, args40[0]), " ", rt.fmtSpec({ plus: true, zero: true, width: 6 }, args40[0]), " ", rt.fmtSpec({ plus: true, alternate: true }, args40[1]), " ", args40[0], " ", rt.fmtSpec({ precision: 3 }, args40[0]), " ", rt.fmtSpec({ width: 8, precision: 2 }, args40[0]), "|", args40[2], " ", rt.fmtSpec({ alternate: true }, args40[2]), " ", rt.fmtSpec({ alternate: true, zero: true, width: 12 }, args40[2]), " ", args40[3], " ", rt.fmtSpec({ alternate: true }, args40[3]), " ", rt.fmtSpec({ plus: true }, args40[3]), "|", rt.fmtSpec({ debugHex: "x" }, args40[4]), " ", rt.fmtSpec({ alternate: true, debugHex: "X" }, args40[4]), " ", rt.fmtSpec({ zero: true, debugHex: "x", width: 6 }, args40[4]), " ", rt.fmtSpec({ plus: true }, args40[4])])); + const args42: rt.Fmt[] = [(f: rt.Formatter) => rt.i8LowerExp(v7, f), (f: rt.Formatter) => rt.i8UpperExp(v7, f)]; + put(out, rt.fmtFormat([args42[0], " ", args42[1], " ", rt.fmtSpec({ precision: 0 }, args42[0]), " ", rt.fmtSpec({ precision: 1 }, args42[0]), " ", rt.fmtSpec({ precision: 3 }, args42[0]), " ", rt.fmtSpec({ precision: 45 }, args42[1]), " ", rt.fmtSpec({ plus: true, precision: 2 }, args42[0]), " ", rt.fmtSpec({ zero: true, width: 12, precision: 1 }, args42[0]), " ", rt.fmtSpec({ align: "<", plus: true, width: 9 }, args42[0]), "| ", rt.fmtSpec({ alternate: true }, args42[0]), " ", rt.fmtSpec({ align: ">", width: 12, precision: 4 }, args42[1]), "|"])); put(out, rt.fmtToString((f: rt.Formatter) => rt.i8Display(v7, f))); } else if (_4 === 7) { const buf8: Uint8Array = rt.bytes(2); const n8: rt.usize = rt.min(data.length, rt.byteSliceFrom(buf8).length); rt.byteSliceCopyFromSlice(rt.byteSliceRange(rt.byteSliceFrom(buf8), 0, n8), rt.byteSliceRange(data, 0, n8)); const v8: rt.i16 = rt.i16FromBeBytes(buf8); - const args16: rt.Fmt[] = [(f: rt.Formatter) => rt.i16Display(v8, f), (f: rt.Formatter) => rt.i16Display(v8, f), (f: rt.Formatter) => rt.i16LowerHex(v8, f), (f: rt.Formatter) => rt.i16UpperHex(v8, f)]; - put(out, rt.fmtFormat([args16[0], " ", args16[1], " ", rt.fmtSpec({ width: 5 }, args16[0]), "|", rt.fmtSpec({ align: "<", width: 5 }, args16[0]), "|", rt.fmtSpec({ align: "^", width: 7 }, args16[0]), "|", rt.fmtSpec({ align: ">", width: 4 }, args16[0]), "|", rt.fmtSpec({ fill: "*", align: "^", width: 9 }, args16[0]), "|", rt.fmtSpec({ fill: "é", align: ">", width: 6 }, args16[0]), "|", rt.fmtSpec({ zero: true, width: 5 }, args16[0]), "|", rt.fmtSpec({ align: "<", zero: true, width: 5 }, args16[0]), "|", args16[2], " ", args16[3], " ", rt.fmtSpec({ alternate: true }, args16[2]), " ", rt.fmtSpec({ alternate: true }, args16[3]), " ", rt.fmtSpec({ zero: true, width: 8 }, args16[2]), " ", rt.fmtSpec({ alternate: true, zero: true, width: 10 }, args16[2]), " ", rt.fmtSpec({ align: ">", width: 8 }, args16[2]), "|", rt.fmtSpec({ align: "<", alternate: true, width: 6 }, args16[3]), "|", rt.fmtSpec({ alternate: true }, args16[1]), " ", rt.fmtSpec({ width: 3 }, args16[1])])); + const args44: rt.Fmt[] = [(f: rt.Formatter) => rt.i16Display(v8, f), (f: rt.Formatter) => rt.i16Debug(v8, f), (f: rt.Formatter) => rt.i16LowerHex(v8, f), (f: rt.Formatter) => rt.i16UpperHex(v8, f)]; + put(out, rt.fmtFormat([args44[0], " ", args44[1], " ", rt.fmtSpec({ width: 5 }, args44[0]), "|", rt.fmtSpec({ align: "<", width: 5 }, args44[0]), "|", rt.fmtSpec({ align: "^", width: 7 }, args44[0]), "|", rt.fmtSpec({ align: ">", width: 4 }, args44[0]), "|", rt.fmtSpec({ fill: "*", align: "^", width: 9 }, args44[0]), "|", rt.fmtSpec({ fill: "é", align: ">", width: 6 }, args44[0]), "|", rt.fmtSpec({ zero: true, width: 5 }, args44[0]), "|", rt.fmtSpec({ align: "<", zero: true, width: 5 }, args44[0]), "|", args44[2], " ", args44[3], " ", rt.fmtSpec({ alternate: true }, args44[2]), " ", rt.fmtSpec({ alternate: true }, args44[3]), " ", rt.fmtSpec({ zero: true, width: 8 }, args44[2]), " ", rt.fmtSpec({ alternate: true, zero: true, width: 10 }, args44[2]), " ", rt.fmtSpec({ align: ">", width: 8 }, args44[2]), "|", rt.fmtSpec({ align: "<", alternate: true, width: 6 }, args44[3]), "|", rt.fmtSpec({ alternate: true }, args44[1]), " ", rt.fmtSpec({ width: 3 }, args44[1])])); + const args46: rt.Fmt[] = [(f: rt.Formatter) => rt.i16Display(v8, f), (f: rt.Formatter) => rt.i16LowerHex(v8, f), (f: rt.Formatter) => rt.i16Binary(v8, f), (f: rt.Formatter) => rt.i16Octal(v8, f), (f: rt.Formatter) => rt.i16Debug(v8, f)]; + put(out, rt.fmtFormat([rt.fmtSpec({ plus: true }, args46[0]), " ", rt.fmtSpec({ plus: true, zero: true, width: 6 }, args46[0]), " ", rt.fmtSpec({ plus: true, alternate: true }, args46[1]), " ", args46[0], " ", rt.fmtSpec({ precision: 3 }, args46[0]), " ", rt.fmtSpec({ width: 8, precision: 2 }, args46[0]), "|", args46[2], " ", rt.fmtSpec({ alternate: true }, args46[2]), " ", rt.fmtSpec({ alternate: true, zero: true, width: 12 }, args46[2]), " ", args46[3], " ", rt.fmtSpec({ alternate: true }, args46[3]), " ", rt.fmtSpec({ plus: true }, args46[3]), "|", rt.fmtSpec({ debugHex: "x" }, args46[4]), " ", rt.fmtSpec({ alternate: true, debugHex: "X" }, args46[4]), " ", rt.fmtSpec({ zero: true, debugHex: "x", width: 6 }, args46[4]), " ", rt.fmtSpec({ plus: true }, args46[4])])); + const args48: rt.Fmt[] = [(f: rt.Formatter) => rt.i16LowerExp(v8, f), (f: rt.Formatter) => rt.i16UpperExp(v8, f)]; + put(out, rt.fmtFormat([args48[0], " ", args48[1], " ", rt.fmtSpec({ precision: 0 }, args48[0]), " ", rt.fmtSpec({ precision: 1 }, args48[0]), " ", rt.fmtSpec({ precision: 3 }, args48[0]), " ", rt.fmtSpec({ precision: 45 }, args48[1]), " ", rt.fmtSpec({ plus: true, precision: 2 }, args48[0]), " ", rt.fmtSpec({ zero: true, width: 12, precision: 1 }, args48[0]), " ", rt.fmtSpec({ align: "<", plus: true, width: 9 }, args48[0]), "| ", rt.fmtSpec({ alternate: true }, args48[0]), " ", rt.fmtSpec({ align: ">", width: 12, precision: 4 }, args48[1]), "|"])); put(out, rt.fmtToString((f: rt.Formatter) => rt.i16Display(v8, f))); } else if (_4 === 8) { const buf9: Uint8Array = rt.bytes(4); const n9: rt.usize = rt.min(data.length, rt.byteSliceFrom(buf9).length); rt.byteSliceCopyFromSlice(rt.byteSliceRange(rt.byteSliceFrom(buf9), 0, n9), rt.byteSliceRange(data, 0, n9)); const v9: rt.i32 = rt.i32FromBeBytes(buf9); - const args18: rt.Fmt[] = [(f: rt.Formatter) => rt.i32Display(v9, f), (f: rt.Formatter) => rt.i32Display(v9, f), (f: rt.Formatter) => rt.i32LowerHex(v9, f), (f: rt.Formatter) => rt.i32UpperHex(v9, f)]; - put(out, rt.fmtFormat([args18[0], " ", args18[1], " ", rt.fmtSpec({ width: 5 }, args18[0]), "|", rt.fmtSpec({ align: "<", width: 5 }, args18[0]), "|", rt.fmtSpec({ align: "^", width: 7 }, args18[0]), "|", rt.fmtSpec({ align: ">", width: 4 }, args18[0]), "|", rt.fmtSpec({ fill: "*", align: "^", width: 9 }, args18[0]), "|", rt.fmtSpec({ fill: "é", align: ">", width: 6 }, args18[0]), "|", rt.fmtSpec({ zero: true, width: 5 }, args18[0]), "|", rt.fmtSpec({ align: "<", zero: true, width: 5 }, args18[0]), "|", args18[2], " ", args18[3], " ", rt.fmtSpec({ alternate: true }, args18[2]), " ", rt.fmtSpec({ alternate: true }, args18[3]), " ", rt.fmtSpec({ zero: true, width: 8 }, args18[2]), " ", rt.fmtSpec({ alternate: true, zero: true, width: 10 }, args18[2]), " ", rt.fmtSpec({ align: ">", width: 8 }, args18[2]), "|", rt.fmtSpec({ align: "<", alternate: true, width: 6 }, args18[3]), "|", rt.fmtSpec({ alternate: true }, args18[1]), " ", rt.fmtSpec({ width: 3 }, args18[1])])); + const args50: rt.Fmt[] = [(f: rt.Formatter) => rt.i32Display(v9, f), (f: rt.Formatter) => rt.i32Debug(v9, f), (f: rt.Formatter) => rt.i32LowerHex(v9, f), (f: rt.Formatter) => rt.i32UpperHex(v9, f)]; + put(out, rt.fmtFormat([args50[0], " ", args50[1], " ", rt.fmtSpec({ width: 5 }, args50[0]), "|", rt.fmtSpec({ align: "<", width: 5 }, args50[0]), "|", rt.fmtSpec({ align: "^", width: 7 }, args50[0]), "|", rt.fmtSpec({ align: ">", width: 4 }, args50[0]), "|", rt.fmtSpec({ fill: "*", align: "^", width: 9 }, args50[0]), "|", rt.fmtSpec({ fill: "é", align: ">", width: 6 }, args50[0]), "|", rt.fmtSpec({ zero: true, width: 5 }, args50[0]), "|", rt.fmtSpec({ align: "<", zero: true, width: 5 }, args50[0]), "|", args50[2], " ", args50[3], " ", rt.fmtSpec({ alternate: true }, args50[2]), " ", rt.fmtSpec({ alternate: true }, args50[3]), " ", rt.fmtSpec({ zero: true, width: 8 }, args50[2]), " ", rt.fmtSpec({ alternate: true, zero: true, width: 10 }, args50[2]), " ", rt.fmtSpec({ align: ">", width: 8 }, args50[2]), "|", rt.fmtSpec({ align: "<", alternate: true, width: 6 }, args50[3]), "|", rt.fmtSpec({ alternate: true }, args50[1]), " ", rt.fmtSpec({ width: 3 }, args50[1])])); + const args52: rt.Fmt[] = [(f: rt.Formatter) => rt.i32Display(v9, f), (f: rt.Formatter) => rt.i32LowerHex(v9, f), (f: rt.Formatter) => rt.i32Binary(v9, f), (f: rt.Formatter) => rt.i32Octal(v9, f), (f: rt.Formatter) => rt.i32Debug(v9, f)]; + put(out, rt.fmtFormat([rt.fmtSpec({ plus: true }, args52[0]), " ", rt.fmtSpec({ plus: true, zero: true, width: 6 }, args52[0]), " ", rt.fmtSpec({ plus: true, alternate: true }, args52[1]), " ", args52[0], " ", rt.fmtSpec({ precision: 3 }, args52[0]), " ", rt.fmtSpec({ width: 8, precision: 2 }, args52[0]), "|", args52[2], " ", rt.fmtSpec({ alternate: true }, args52[2]), " ", rt.fmtSpec({ alternate: true, zero: true, width: 12 }, args52[2]), " ", args52[3], " ", rt.fmtSpec({ alternate: true }, args52[3]), " ", rt.fmtSpec({ plus: true }, args52[3]), "|", rt.fmtSpec({ debugHex: "x" }, args52[4]), " ", rt.fmtSpec({ alternate: true, debugHex: "X" }, args52[4]), " ", rt.fmtSpec({ zero: true, debugHex: "x", width: 6 }, args52[4]), " ", rt.fmtSpec({ plus: true }, args52[4])])); + const args54: rt.Fmt[] = [(f: rt.Formatter) => rt.i32LowerExp(v9, f), (f: rt.Formatter) => rt.i32UpperExp(v9, f)]; + put(out, rt.fmtFormat([args54[0], " ", args54[1], " ", rt.fmtSpec({ precision: 0 }, args54[0]), " ", rt.fmtSpec({ precision: 1 }, args54[0]), " ", rt.fmtSpec({ precision: 3 }, args54[0]), " ", rt.fmtSpec({ precision: 45 }, args54[1]), " ", rt.fmtSpec({ plus: true, precision: 2 }, args54[0]), " ", rt.fmtSpec({ zero: true, width: 12, precision: 1 }, args54[0]), " ", rt.fmtSpec({ align: "<", plus: true, width: 9 }, args54[0]), "| ", rt.fmtSpec({ alternate: true }, args54[0]), " ", rt.fmtSpec({ align: ">", width: 12, precision: 4 }, args54[1]), "|"])); put(out, rt.fmtToString((f: rt.Formatter) => rt.i32Display(v9, f))); } else if (_4 === 9) { const buf10: Uint8Array = rt.bytes(8); const n10: rt.usize = rt.min(data.length, rt.byteSliceFrom(buf10).length); rt.byteSliceCopyFromSlice(rt.byteSliceRange(rt.byteSliceFrom(buf10), 0, n10), rt.byteSliceRange(data, 0, n10)); const v10: rt.i64 = rt.i64FromBeBytes(buf10); - const args20: rt.Fmt[] = [(f: rt.Formatter) => rt.i64Display(v10, f), (f: rt.Formatter) => rt.i64Display(v10, f), (f: rt.Formatter) => rt.i64LowerHex(v10, f), (f: rt.Formatter) => rt.i64UpperHex(v10, f)]; - put(out, rt.fmtFormat([args20[0], " ", args20[1], " ", rt.fmtSpec({ width: 5 }, args20[0]), "|", rt.fmtSpec({ align: "<", width: 5 }, args20[0]), "|", rt.fmtSpec({ align: "^", width: 7 }, args20[0]), "|", rt.fmtSpec({ align: ">", width: 4 }, args20[0]), "|", rt.fmtSpec({ fill: "*", align: "^", width: 9 }, args20[0]), "|", rt.fmtSpec({ fill: "é", align: ">", width: 6 }, args20[0]), "|", rt.fmtSpec({ zero: true, width: 5 }, args20[0]), "|", rt.fmtSpec({ align: "<", zero: true, width: 5 }, args20[0]), "|", args20[2], " ", args20[3], " ", rt.fmtSpec({ alternate: true }, args20[2]), " ", rt.fmtSpec({ alternate: true }, args20[3]), " ", rt.fmtSpec({ zero: true, width: 8 }, args20[2]), " ", rt.fmtSpec({ alternate: true, zero: true, width: 10 }, args20[2]), " ", rt.fmtSpec({ align: ">", width: 8 }, args20[2]), "|", rt.fmtSpec({ align: "<", alternate: true, width: 6 }, args20[3]), "|", rt.fmtSpec({ alternate: true }, args20[1]), " ", rt.fmtSpec({ width: 3 }, args20[1])])); + const args56: rt.Fmt[] = [(f: rt.Formatter) => rt.i64Display(v10, f), (f: rt.Formatter) => rt.i64Debug(v10, f), (f: rt.Formatter) => rt.i64LowerHex(v10, f), (f: rt.Formatter) => rt.i64UpperHex(v10, f)]; + put(out, rt.fmtFormat([args56[0], " ", args56[1], " ", rt.fmtSpec({ width: 5 }, args56[0]), "|", rt.fmtSpec({ align: "<", width: 5 }, args56[0]), "|", rt.fmtSpec({ align: "^", width: 7 }, args56[0]), "|", rt.fmtSpec({ align: ">", width: 4 }, args56[0]), "|", rt.fmtSpec({ fill: "*", align: "^", width: 9 }, args56[0]), "|", rt.fmtSpec({ fill: "é", align: ">", width: 6 }, args56[0]), "|", rt.fmtSpec({ zero: true, width: 5 }, args56[0]), "|", rt.fmtSpec({ align: "<", zero: true, width: 5 }, args56[0]), "|", args56[2], " ", args56[3], " ", rt.fmtSpec({ alternate: true }, args56[2]), " ", rt.fmtSpec({ alternate: true }, args56[3]), " ", rt.fmtSpec({ zero: true, width: 8 }, args56[2]), " ", rt.fmtSpec({ alternate: true, zero: true, width: 10 }, args56[2]), " ", rt.fmtSpec({ align: ">", width: 8 }, args56[2]), "|", rt.fmtSpec({ align: "<", alternate: true, width: 6 }, args56[3]), "|", rt.fmtSpec({ alternate: true }, args56[1]), " ", rt.fmtSpec({ width: 3 }, args56[1])])); + const args58: rt.Fmt[] = [(f: rt.Formatter) => rt.i64Display(v10, f), (f: rt.Formatter) => rt.i64LowerHex(v10, f), (f: rt.Formatter) => rt.i64Binary(v10, f), (f: rt.Formatter) => rt.i64Octal(v10, f), (f: rt.Formatter) => rt.i64Debug(v10, f)]; + put(out, rt.fmtFormat([rt.fmtSpec({ plus: true }, args58[0]), " ", rt.fmtSpec({ plus: true, zero: true, width: 6 }, args58[0]), " ", rt.fmtSpec({ plus: true, alternate: true }, args58[1]), " ", args58[0], " ", rt.fmtSpec({ precision: 3 }, args58[0]), " ", rt.fmtSpec({ width: 8, precision: 2 }, args58[0]), "|", args58[2], " ", rt.fmtSpec({ alternate: true }, args58[2]), " ", rt.fmtSpec({ alternate: true, zero: true, width: 12 }, args58[2]), " ", args58[3], " ", rt.fmtSpec({ alternate: true }, args58[3]), " ", rt.fmtSpec({ plus: true }, args58[3]), "|", rt.fmtSpec({ debugHex: "x" }, args58[4]), " ", rt.fmtSpec({ alternate: true, debugHex: "X" }, args58[4]), " ", rt.fmtSpec({ zero: true, debugHex: "x", width: 6 }, args58[4]), " ", rt.fmtSpec({ plus: true }, args58[4])])); + const args60: rt.Fmt[] = [(f: rt.Formatter) => rt.i64LowerExp(v10, f), (f: rt.Formatter) => rt.i64UpperExp(v10, f)]; + put(out, rt.fmtFormat([args60[0], " ", args60[1], " ", rt.fmtSpec({ precision: 0 }, args60[0]), " ", rt.fmtSpec({ precision: 1 }, args60[0]), " ", rt.fmtSpec({ precision: 3 }, args60[0]), " ", rt.fmtSpec({ precision: 45 }, args60[1]), " ", rt.fmtSpec({ plus: true, precision: 2 }, args60[0]), " ", rt.fmtSpec({ zero: true, width: 12, precision: 1 }, args60[0]), " ", rt.fmtSpec({ align: "<", plus: true, width: 9 }, args60[0]), "| ", rt.fmtSpec({ alternate: true }, args60[0]), " ", rt.fmtSpec({ align: ">", width: 12, precision: 4 }, args60[1]), "|"])); put(out, rt.fmtToString((f: rt.Formatter) => rt.i64Display(v10, f))); } else if (_4 === 10) { const buf11: Uint8Array = rt.bytes(16); const n11: rt.usize = rt.min(data.length, rt.byteSliceFrom(buf11).length); rt.byteSliceCopyFromSlice(rt.byteSliceRange(rt.byteSliceFrom(buf11), 0, n11), rt.byteSliceRange(data, 0, n11)); const v11: rt.i128 = rt.i128FromBeBytes(buf11); - const args22: rt.Fmt[] = [(f: rt.Formatter) => rt.i128Display(v11, f), (f: rt.Formatter) => rt.i128Display(v11, f), (f: rt.Formatter) => rt.i128LowerHex(v11, f), (f: rt.Formatter) => rt.i128UpperHex(v11, f)]; - put(out, rt.fmtFormat([args22[0], " ", args22[1], " ", rt.fmtSpec({ width: 5 }, args22[0]), "|", rt.fmtSpec({ align: "<", width: 5 }, args22[0]), "|", rt.fmtSpec({ align: "^", width: 7 }, args22[0]), "|", rt.fmtSpec({ align: ">", width: 4 }, args22[0]), "|", rt.fmtSpec({ fill: "*", align: "^", width: 9 }, args22[0]), "|", rt.fmtSpec({ fill: "é", align: ">", width: 6 }, args22[0]), "|", rt.fmtSpec({ zero: true, width: 5 }, args22[0]), "|", rt.fmtSpec({ align: "<", zero: true, width: 5 }, args22[0]), "|", args22[2], " ", args22[3], " ", rt.fmtSpec({ alternate: true }, args22[2]), " ", rt.fmtSpec({ alternate: true }, args22[3]), " ", rt.fmtSpec({ zero: true, width: 8 }, args22[2]), " ", rt.fmtSpec({ alternate: true, zero: true, width: 10 }, args22[2]), " ", rt.fmtSpec({ align: ">", width: 8 }, args22[2]), "|", rt.fmtSpec({ align: "<", alternate: true, width: 6 }, args22[3]), "|", rt.fmtSpec({ alternate: true }, args22[1]), " ", rt.fmtSpec({ width: 3 }, args22[1])])); + const args62: rt.Fmt[] = [(f: rt.Formatter) => rt.i128Display(v11, f), (f: rt.Formatter) => rt.i128Debug(v11, f), (f: rt.Formatter) => rt.i128LowerHex(v11, f), (f: rt.Formatter) => rt.i128UpperHex(v11, f)]; + put(out, rt.fmtFormat([args62[0], " ", args62[1], " ", rt.fmtSpec({ width: 5 }, args62[0]), "|", rt.fmtSpec({ align: "<", width: 5 }, args62[0]), "|", rt.fmtSpec({ align: "^", width: 7 }, args62[0]), "|", rt.fmtSpec({ align: ">", width: 4 }, args62[0]), "|", rt.fmtSpec({ fill: "*", align: "^", width: 9 }, args62[0]), "|", rt.fmtSpec({ fill: "é", align: ">", width: 6 }, args62[0]), "|", rt.fmtSpec({ zero: true, width: 5 }, args62[0]), "|", rt.fmtSpec({ align: "<", zero: true, width: 5 }, args62[0]), "|", args62[2], " ", args62[3], " ", rt.fmtSpec({ alternate: true }, args62[2]), " ", rt.fmtSpec({ alternate: true }, args62[3]), " ", rt.fmtSpec({ zero: true, width: 8 }, args62[2]), " ", rt.fmtSpec({ alternate: true, zero: true, width: 10 }, args62[2]), " ", rt.fmtSpec({ align: ">", width: 8 }, args62[2]), "|", rt.fmtSpec({ align: "<", alternate: true, width: 6 }, args62[3]), "|", rt.fmtSpec({ alternate: true }, args62[1]), " ", rt.fmtSpec({ width: 3 }, args62[1])])); + const args64: rt.Fmt[] = [(f: rt.Formatter) => rt.i128Display(v11, f), (f: rt.Formatter) => rt.i128LowerHex(v11, f), (f: rt.Formatter) => rt.i128Binary(v11, f), (f: rt.Formatter) => rt.i128Octal(v11, f), (f: rt.Formatter) => rt.i128Debug(v11, f)]; + put(out, rt.fmtFormat([rt.fmtSpec({ plus: true }, args64[0]), " ", rt.fmtSpec({ plus: true, zero: true, width: 6 }, args64[0]), " ", rt.fmtSpec({ plus: true, alternate: true }, args64[1]), " ", args64[0], " ", rt.fmtSpec({ precision: 3 }, args64[0]), " ", rt.fmtSpec({ width: 8, precision: 2 }, args64[0]), "|", args64[2], " ", rt.fmtSpec({ alternate: true }, args64[2]), " ", rt.fmtSpec({ alternate: true, zero: true, width: 12 }, args64[2]), " ", args64[3], " ", rt.fmtSpec({ alternate: true }, args64[3]), " ", rt.fmtSpec({ plus: true }, args64[3]), "|", rt.fmtSpec({ debugHex: "x" }, args64[4]), " ", rt.fmtSpec({ alternate: true, debugHex: "X" }, args64[4]), " ", rt.fmtSpec({ zero: true, debugHex: "x", width: 6 }, args64[4]), " ", rt.fmtSpec({ plus: true }, args64[4])])); + const args66: rt.Fmt[] = [(f: rt.Formatter) => rt.i128LowerExp(v11, f), (f: rt.Formatter) => rt.i128UpperExp(v11, f)]; + put(out, rt.fmtFormat([args66[0], " ", args66[1], " ", rt.fmtSpec({ precision: 0 }, args66[0]), " ", rt.fmtSpec({ precision: 1 }, args66[0]), " ", rt.fmtSpec({ precision: 3 }, args66[0]), " ", rt.fmtSpec({ precision: 45 }, args66[1]), " ", rt.fmtSpec({ plus: true, precision: 2 }, args66[0]), " ", rt.fmtSpec({ zero: true, width: 12, precision: 1 }, args66[0]), " ", rt.fmtSpec({ align: "<", plus: true, width: 9 }, args66[0]), "| ", rt.fmtSpec({ alternate: true }, args66[0]), " ", rt.fmtSpec({ align: ">", width: 12, precision: 4 }, args66[1]), "|"])); put(out, rt.fmtToString((f: rt.Formatter) => rt.i128Display(v11, f))); } else { const buf12: Uint8Array = rt.bytes(4); const n12: rt.usize = rt.min(data.length, rt.byteSliceFrom(buf12).length); rt.byteSliceCopyFromSlice(rt.byteSliceRange(rt.byteSliceFrom(buf12), 0, n12), rt.byteSliceRange(data, 0, n12)); const v12: rt.isize = rt.isizeFromBeBytes(buf12); - const args24: rt.Fmt[] = [(f: rt.Formatter) => rt.isizeDisplay(v12, f), (f: rt.Formatter) => rt.isizeDisplay(v12, f), (f: rt.Formatter) => rt.isizeLowerHex(v12, f), (f: rt.Formatter) => rt.isizeUpperHex(v12, f)]; - put(out, rt.fmtFormat([args24[0], " ", args24[1], " ", rt.fmtSpec({ width: 5 }, args24[0]), "|", rt.fmtSpec({ align: "<", width: 5 }, args24[0]), "|", rt.fmtSpec({ align: "^", width: 7 }, args24[0]), "|", rt.fmtSpec({ align: ">", width: 4 }, args24[0]), "|", rt.fmtSpec({ fill: "*", align: "^", width: 9 }, args24[0]), "|", rt.fmtSpec({ fill: "é", align: ">", width: 6 }, args24[0]), "|", rt.fmtSpec({ zero: true, width: 5 }, args24[0]), "|", rt.fmtSpec({ align: "<", zero: true, width: 5 }, args24[0]), "|", args24[2], " ", args24[3], " ", rt.fmtSpec({ alternate: true }, args24[2]), " ", rt.fmtSpec({ alternate: true }, args24[3]), " ", rt.fmtSpec({ zero: true, width: 8 }, args24[2]), " ", rt.fmtSpec({ alternate: true, zero: true, width: 10 }, args24[2]), " ", rt.fmtSpec({ align: ">", width: 8 }, args24[2]), "|", rt.fmtSpec({ align: "<", alternate: true, width: 6 }, args24[3]), "|", rt.fmtSpec({ alternate: true }, args24[1]), " ", rt.fmtSpec({ width: 3 }, args24[1])])); + const args68: rt.Fmt[] = [(f: rt.Formatter) => rt.isizeDisplay(v12, f), (f: rt.Formatter) => rt.isizeDebug(v12, f), (f: rt.Formatter) => rt.isizeLowerHex(v12, f), (f: rt.Formatter) => rt.isizeUpperHex(v12, f)]; + put(out, rt.fmtFormat([args68[0], " ", args68[1], " ", rt.fmtSpec({ width: 5 }, args68[0]), "|", rt.fmtSpec({ align: "<", width: 5 }, args68[0]), "|", rt.fmtSpec({ align: "^", width: 7 }, args68[0]), "|", rt.fmtSpec({ align: ">", width: 4 }, args68[0]), "|", rt.fmtSpec({ fill: "*", align: "^", width: 9 }, args68[0]), "|", rt.fmtSpec({ fill: "é", align: ">", width: 6 }, args68[0]), "|", rt.fmtSpec({ zero: true, width: 5 }, args68[0]), "|", rt.fmtSpec({ align: "<", zero: true, width: 5 }, args68[0]), "|", args68[2], " ", args68[3], " ", rt.fmtSpec({ alternate: true }, args68[2]), " ", rt.fmtSpec({ alternate: true }, args68[3]), " ", rt.fmtSpec({ zero: true, width: 8 }, args68[2]), " ", rt.fmtSpec({ alternate: true, zero: true, width: 10 }, args68[2]), " ", rt.fmtSpec({ align: ">", width: 8 }, args68[2]), "|", rt.fmtSpec({ align: "<", alternate: true, width: 6 }, args68[3]), "|", rt.fmtSpec({ alternate: true }, args68[1]), " ", rt.fmtSpec({ width: 3 }, args68[1])])); + const args70: rt.Fmt[] = [(f: rt.Formatter) => rt.isizeDisplay(v12, f), (f: rt.Formatter) => rt.isizeLowerHex(v12, f), (f: rt.Formatter) => rt.isizeBinary(v12, f), (f: rt.Formatter) => rt.isizeOctal(v12, f), (f: rt.Formatter) => rt.isizeDebug(v12, f)]; + put(out, rt.fmtFormat([rt.fmtSpec({ plus: true }, args70[0]), " ", rt.fmtSpec({ plus: true, zero: true, width: 6 }, args70[0]), " ", rt.fmtSpec({ plus: true, alternate: true }, args70[1]), " ", args70[0], " ", rt.fmtSpec({ precision: 3 }, args70[0]), " ", rt.fmtSpec({ width: 8, precision: 2 }, args70[0]), "|", args70[2], " ", rt.fmtSpec({ alternate: true }, args70[2]), " ", rt.fmtSpec({ alternate: true, zero: true, width: 12 }, args70[2]), " ", args70[3], " ", rt.fmtSpec({ alternate: true }, args70[3]), " ", rt.fmtSpec({ plus: true }, args70[3]), "|", rt.fmtSpec({ debugHex: "x" }, args70[4]), " ", rt.fmtSpec({ alternate: true, debugHex: "X" }, args70[4]), " ", rt.fmtSpec({ zero: true, debugHex: "x", width: 6 }, args70[4]), " ", rt.fmtSpec({ plus: true }, args70[4])])); + const args72: rt.Fmt[] = [(f: rt.Formatter) => rt.isizeLowerExp(v12, f), (f: rt.Formatter) => rt.isizeUpperExp(v12, f)]; + put(out, rt.fmtFormat([args72[0], " ", args72[1], " ", rt.fmtSpec({ precision: 0 }, args72[0]), " ", rt.fmtSpec({ precision: 1 }, args72[0]), " ", rt.fmtSpec({ precision: 3 }, args72[0]), " ", rt.fmtSpec({ precision: 45 }, args72[1]), " ", rt.fmtSpec({ plus: true, precision: 2 }, args72[0]), " ", rt.fmtSpec({ zero: true, width: 12, precision: 1 }, args72[0]), " ", rt.fmtSpec({ align: "<", plus: true, width: 9 }, args72[0]), "| ", rt.fmtSpec({ alternate: true }, args72[0]), " ", rt.fmtSpec({ align: ">", width: 12, precision: 4 }, args72[1]), "|"])); put(out, rt.fmtToString((f: rt.Formatter) => rt.isizeDisplay(v12, f))); } } @@ -135,43 +183,48 @@ export function strings(data: rt.ByteSlice, out: rt.ByteVec): void { if (!(_15 < 14)) { rt.panic("index out of bounds: the len is " + 14 + " but the index is " + _15); } - const part2 = ["", "a", "héllo", "日本語", "tab\tnew\nline\r", "quote\"back\\slash'", "\u0000\u0001\u001f", "€Ÿ ­", "é", "‍ᅟ\u2028 ", "͸􏿽", "😀 🇦", "゙゚ン", "{}"][_15]; - const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, part2), (f: rt.Formatter) => rt.fmtStr(part2, f)]; + const s: string = ["", "a", "héllo", "日本語", "tab\tnew\nline\r", "quote\"back\\slash'", "\u0000\u0001\u001f", "€Ÿ ­", "é", "‍ᅟ\u2028 ", "͸􏿽", "😀 🇦", "゙゚ン", "{}"][_15]; + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, s), (f: rt.Formatter) => rt.fmtStr(s, f)]; put(out, rt.fmtFormat([args2[0], "|", rt.fmtSpec({ width: 8 }, args2[0]), "|", rt.fmtSpec({ align: ">", width: 8 }, args2[0]), "|", rt.fmtSpec({ align: "^", width: 8 }, args2[0]), "|", rt.fmtSpec({ fill: "-", align: "<", width: 3 }, args2[0]), "|", args2[1], "|", rt.fmtSpec({ width: 12 }, args2[1]), "|", rt.fmtSpec({ alternate: true }, args2[1]), "|{", args2[0], "}"])); + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, s), (f: rt.Formatter) => rt.fmtStr(s, f)]; + put(out, rt.fmtFormat([rt.fmtSpec({ precision: 2 }, args4[0]), "|", rt.fmtSpec({ width: 8, precision: 3 }, args4[0]), "|", rt.fmtSpec({ align: ">", width: 6, precision: 1 }, args4[0]), "|", rt.fmtSpec({ fill: "_", align: "^", width: 7, precision: 2 }, args4[0]), "|", rt.fmtSpec({ precision: 0 }, args4[0]), "|", rt.fmtSpec({ precision: 20 }, args4[0]), "|", rt.fmtSpec({ precision: 2 }, args4[1]), "|", rt.fmtSpec({ width: 10, precision: 2 }, args4[1]), "|", rt.fmtSpec({ plus: true }, args4[0])])); } - const _36: rt.Result = rt.stringFromUtf8(rt.byteSliceToByteVec(data)); - if (_36.ok) { - const s: string = _36.value; - const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtStr(s, f), (f: rt.Formatter) => rt.fmtPad(f, s)]; - put(out, rt.fmtFormat([args4[0], " ", rt.fmtSpec({ align: ">", width: 4 }, args4[1])])); + const c: rt.char = unwrapOr$Option_char(rt.charFromU32(rt.u32Mul(unwrapOr$Option_u8(rt.byteSliceFirst(data), 0) as rt.u32, 257)), 63); + const args6: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtCharDisplay(c, f), (f: rt.Formatter) => rt.fmtCharDebug(c, f)]; + put(out, rt.fmtFormat([args6[0], "|", rt.fmtSpec({ precision: 0 }, args6[0]), "|", rt.fmtSpec({ width: 3, precision: 1 }, args6[0]), "|", rt.fmtSpec({ precision: 0 }, args6[1]), "|", rt.fmtSpec({ align: ">", width: 4 }, args6[1])])); + const _70: rt.Result = rt.stringFromUtf8(rt.byteSliceToByteVec(data)); + if (_70.ok) { + const s2: string = _70.value; + const args8: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtStr(s2, f), (f: rt.Formatter) => rt.fmtPad(f, s2)]; + put(out, rt.fmtFormat([args8[0], " ", rt.fmtSpec({ align: ">", width: 4 }, args8[1]), " ", rt.fmtSpec({ precision: 1 }, args8[1])])); } else { - const e: rt.FromUtf8Error = _36.error; - const args6: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtFromUtf8ErrorDisplay(e, f), (f: rt.Formatter) => rt.fmtFromUtf8ErrorDebug(e, f)]; - put(out, rt.fmtFormat([args6[0], " ", args6[1], " ", rt.fmtSpec({ alternate: true }, args6[1]), " ", rt.fmtSpec({ align: ">", width: 80 }, args6[0])])); + const e: rt.FromUtf8Error = _70.error; + const args10: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtFromUtf8ErrorDisplay(e, f), (f: rt.Formatter) => rt.fmtFromUtf8ErrorDebug(e, f)]; + put(out, rt.fmtFormat([args10[0], " ", args10[1], " ", rt.fmtSpec({ alternate: true }, args10[1]), " ", rt.fmtSpec({ align: ">", width: 80 }, args10[0]), " ", rt.fmtSpec({ precision: 4 }, args10[0]), " ", rt.fmtSpec({ debugHex: "x" }, args10[1]), " ", rt.fmtSpec({ alternate: true, debugHex: "X" }, args10[1])])); } - const _66: rt.u8 | undefined = rt.byteSliceFirst(data); + const _100: rt.u8 | undefined = rt.byteSliceFirst(data); b3: { - if (_66 !== undefined) { - if (rt.u8Rem(_66, 2) === 0) { + if (_100 !== undefined) { + if (rt.u8Rem(_100, 2) === 0) { flag = true; break b3; } } flag = false; } - const args8: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtBool(flag, f), (f: rt.Formatter) => rt.fmtBool(flag, f), (f: rt.Formatter) => rt.fmtUnit(undefined, f), (f: rt.Formatter) => rt.fmtUnit(undefined, f)]; - put(out, rt.fmtFormat([args8[0], " ", args8[1], " ", rt.fmtSpec({ align: ">", width: 6 }, args8[0]), " ", args8[2], " ", rt.fmtSpec({ alternate: true }, args8[3])])); - const _94: boolean = flag; - put(out, rt.fmtToString((f: rt.Formatter) => rt.fmtBool(_94, f))); - const _95: rt.Result = rt.u8TryFrom(rt.i32Sub(data.length | 0, 3)); - if (_95.ok) { - const arg = _95.value; - const args10: rt.Fmt[] = [(f: rt.Formatter) => rt.u8Display(arg, f)]; - put(out, rt.fmtFormat([args10[0]])); + const args12: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtBool(flag, f), (f: rt.Formatter) => rt.fmtBool(flag, f), (f: rt.Formatter) => rt.fmtUnit(undefined, f), (f: rt.Formatter) => rt.fmtUnit(undefined, f), (f: rt.Formatter) => rt.fmtUnit(undefined, f)]; + put(out, rt.fmtFormat([args12[0], " ", args12[1], " ", rt.fmtSpec({ align: ">", width: 6 }, args12[0]), " ", rt.fmtSpec({ precision: 2 }, args12[0]), " ", rt.fmtSpec({ align: ">", width: 4, precision: 1 }, args12[1]), " ", args12[2], " ", rt.fmtSpec({ alternate: true }, args12[3]), " ", rt.fmtSpec({ precision: 1 }, args12[4])])); + const _130: boolean = flag; + put(out, rt.fmtToString((f: rt.Formatter) => rt.fmtBool(_130, f))); + const _131: rt.Result = rt.u8TryFrom(rt.i32Sub(data.length | 0, 3)); + if (_131.ok) { + const arg = _131.value; + const args14: rt.Fmt[] = [(f: rt.Formatter) => rt.u8Display(arg, f)]; + put(out, rt.fmtFormat([args14[0]])); } else { - const e2: rt.TryFromIntError = _95.error; - const args12: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtTryFromIntErrorDisplay(e2, f), (f: rt.Formatter) => rt.fmtTryFromIntErrorDebug(e2, f)]; - put(out, rt.fmtFormat([args12[0], " ", args12[1], " ", rt.fmtSpec({ align: ">", width: 40 }, args12[0]), "|"])); + const e2: rt.TryFromIntError = _131.error; + const args16: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtTryFromIntErrorDisplay(e2, f), (f: rt.Formatter) => rt.fmtTryFromIntErrorDebug(e2, f)]; + put(out, rt.fmtFormat([args16[0], " ", args16[1], " ", rt.fmtSpec({ align: ">", width: 40 }, args16[0]), "| ", rt.fmtSpec({ precision: 6 }, args16[0]), "|", rt.fmtSpec({ width: 10, precision: 3 }, args16[0]), "|"])); } } @@ -235,35 +288,41 @@ export function derived(data: rt.ByteSlice, out: rt.ByteVec): void { put(out, rt.fmtFormat([args2[0]])); const args4: rt.Fmt[] = [(f: rt.Formatter) => Nested.fmt$Debug(value, f)]; put(out, rt.fmtFormat([rt.fmtSpec({ alternate: true }, args4[0])])); + const args6: rt.Fmt[] = [(f: rt.Formatter) => Nested.fmt$Debug(value, f)]; + put(out, rt.fmtFormat([rt.fmtSpec({ debugHex: "x" }, args6[0])])); + const args8: rt.Fmt[] = [(f: rt.Formatter) => Nested.fmt$Debug(value, f)]; + put(out, rt.fmtFormat([rt.fmtSpec({ alternate: true, debugHex: "X" }, args8[0])])); + const args10: rt.Fmt[] = [(f: rt.Formatter) => Nested.fmt$Debug(value, f)]; + put(out, rt.fmtFormat([rt.fmtSpec({ plus: true, precision: 1 }, args10[0])])); const wide: Wide.Wide = { a: at(0), b: 300, c: 70000, d: { hi: 0xffffffff, lo: 0xffffffff } as rt.u64, e: -1, f: at(1) > 10 }; const six: Six.Six = { _0: at(0), _1: 1, _2: 2, _3: 3, _4: 4, _5: at(1) }; - const _51: Unit.Unit = {}; - const _52: Unit.Unit = {}; - const args6: rt.Fmt[] = [(f: rt.Formatter) => Wide.fmt$Debug(wide, f), (f: rt.Formatter) => Six.fmt$Debug(six, f), (f: rt.Formatter) => Unit.fmt$Debug(_51, f), (f: rt.Formatter) => Unit.fmt$Debug(_52, f)]; - put(out, rt.fmtFormat([args6[0], " ", args6[1], " ", args6[2], " ", rt.fmtSpec({ alternate: true }, args6[3])])); - const args8: rt.Fmt[] = [(f: rt.Formatter) => Wide.fmt$Debug(wide, f), (f: rt.Formatter) => Six.fmt$Debug(six, f)]; - put(out, rt.fmtFormat([rt.fmtSpec({ alternate: true }, args8[0]), " ", rt.fmtSpec({ alternate: true }, args8[1])])); + const _87: Unit.Unit = {}; + const _88: Unit.Unit = {}; + const args12: rt.Fmt[] = [(f: rt.Formatter) => Wide.fmt$Debug(wide, f), (f: rt.Formatter) => Six.fmt$Debug(six, f), (f: rt.Formatter) => Unit.fmt$Debug(_87, f), (f: rt.Formatter) => Unit.fmt$Debug(_88, f)]; + put(out, rt.fmtFormat([args12[0], " ", args12[1], " ", args12[2], " ", rt.fmtSpec({ alternate: true }, args12[3])])); + const args14: rt.Fmt[] = [(f: rt.Formatter) => Wide.fmt$Debug(wide, f), (f: rt.Formatter) => Six.fmt$Debug(six, f)]; + put(out, rt.fmtFormat([rt.fmtSpec({ alternate: true }, args14[0]), " ", rt.fmtSpec({ alternate: true }, args14[1])])); const point: Point.Point = { x: at(2) as rt.i32, y: -1 }; - const _89: Pair.Pair = { _0: at(3), _1: -9 }; - const args10: rt.Fmt[] = [(f: rt.Formatter) => Point.fmt$Debug(point, f), (f: rt.Formatter) => Pair.fmt$Debug(_89, f)]; - put(out, rt.fmtFormat([rt.fmtSpec({ width: 5 }, args10[0]), "|", rt.fmtSpec({ align: "<", width: 4 }, args10[0]), "|", rt.fmtSpec({ alternate: true, width: 4 }, args10[0]), "|", rt.fmtSpec({ align: ">", width: 3 }, args10[1])])); + const _125: Pair.Pair = { _0: at(3), _1: -9 }; + const args16: rt.Fmt[] = [(f: rt.Formatter) => Point.fmt$Debug(point, f), (f: rt.Formatter) => Pair.fmt$Debug(_125, f)]; + put(out, rt.fmtFormat([rt.fmtSpec({ width: 5 }, args16[0]), "|", rt.fmtSpec({ align: "<", width: 4 }, args16[0]), "|", rt.fmtSpec({ alternate: true, width: 4 }, args16[0]), "|", rt.fmtSpec({ align: ">", width: 3 }, args16[1])])); const kinds: Kind.Kind[] = [{ tag: "Empty" } as Kind.Kind, { tag: "One", _0: at(4) } as Kind.Kind, { tag: "Braced" } as Kind.Kind, { tag: "Bare" } as Kind.Kind, { tag: "Many", count: 0, items: new rt.ByteVec() } as Kind.Kind]; - const _118: Kind.Kind = kinds[1]; - const args12: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(kinds, f, (value: Kind.Kind, f: rt.Formatter) => Kind.fmt$Debug(value, f)), (f: rt.Formatter) => Kind.fmt$Debug(_118, f)]; - put(out, rt.fmtFormat([args12[0], " ", args12[1]])); - const args14: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(kinds, f, (value: Kind.Kind, f: rt.Formatter) => Kind.fmt$Debug(value, f))]; - put(out, rt.fmtFormat([rt.fmtSpec({ alternate: true }, args14[0])])); + const _154: Kind.Kind = kinds[1]; + const args18: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(kinds, f, (value: Kind.Kind, f: rt.Formatter) => Kind.fmt$Debug(value, f)), (f: rt.Formatter) => Kind.fmt$Debug(_154, f)]; + put(out, rt.fmtFormat([args18[0], " ", args18[1]])); + const args20: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(kinds, f, (value: Kind.Kind, f: rt.Formatter) => Kind.fmt$Debug(value, f))]; + put(out, rt.fmtFormat([rt.fmtSpec({ alternate: true }, args20[0])])); const words: rt.u16[] = [at(5) as rt.u16, 65535]; - const _153: rt.u8 | undefined = rt.byteSliceFirst(data); - const _155: rt.u8 | undefined = rt.byteSliceGet(data, 100); - const args16: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(rt.byteSliceView(data), f, rt.u8Display), (f: rt.Formatter) => rt.fmtList(words, f, rt.u16Display), (f: rt.Formatter) => rt.fmtOption(_153, f, rt.u8Display), (f: rt.Formatter) => rt.fmtOption(_155, f, rt.u8Display)]; - put(out, rt.fmtFormat([args16[0], " ", args16[1], " ", args16[2], " ", args16[3]])); - const _172: Braced.Braced = {}; - const _173: Braced.Braced = {}; - const _174: Bare.Bare = {}; - const _175: Bare.Bare = {}; - const args18: rt.Fmt[] = [(f: rt.Formatter) => Braced.fmt$Debug(_172, f), (f: rt.Formatter) => Braced.fmt$Debug(_173, f), (f: rt.Formatter) => Bare.fmt$Debug(_174, f), (f: rt.Formatter) => Bare.fmt$Debug(_175, f)]; - put(out, rt.fmtFormat([args18[0], " ", rt.fmtSpec({ alternate: true }, args18[1]), " ", args18[2], " ", rt.fmtSpec({ alternate: true }, args18[3])])); + const _189: rt.u8 | undefined = rt.byteSliceFirst(data); + const _191: rt.u8 | undefined = rt.byteSliceGet(data, 100); + const args22: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(rt.byteSliceView(data), f, rt.u8Debug), (f: rt.Formatter) => rt.fmtList(words, f, rt.u16Debug), (f: rt.Formatter) => rt.fmtOption(_189, f, rt.u8Debug), (f: rt.Formatter) => rt.fmtOption(_191, f, rt.u8Debug)]; + put(out, rt.fmtFormat([args22[0], " ", args22[1], " ", args22[2], " ", args22[3]])); + const _208: Braced.Braced = {}; + const _209: Braced.Braced = {}; + const _210: Bare.Bare = {}; + const _211: Bare.Bare = {}; + const args24: rt.Fmt[] = [(f: rt.Formatter) => Braced.fmt$Debug(_208, f), (f: rt.Formatter) => Braced.fmt$Debug(_209, f), (f: rt.Formatter) => Bare.fmt$Debug(_210, f), (f: rt.Formatter) => Bare.fmt$Debug(_211, f)]; + put(out, rt.fmtFormat([args24[0], " ", rt.fmtSpec({ alternate: true }, args24[1]), " ", args24[2], " ", rt.fmtSpec({ alternate: true }, args24[3])])); rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(Uint8Array.of(Braced.eq$PartialEq({}, {}) ? 1 : 0, Bare.eq$PartialEq({}, {}) ? 1 : 0))); } @@ -288,71 +347,123 @@ export function logged(log: rt.ByteVec, data: rt.ByteSlice): string { /** Written `Display` and `Debug`, and a `Display` that fails inside `format!`. */ export function written(data: rt.ByteSlice, out: rt.ByteVec): void { - let _100!: rt.u8 | undefined; + let _116!: rt.u8 | undefined; const at: (a0: rt.usize) => rt.u8 = (i: rt.usize): rt.u8 => { return unwrapOr$Option_u8(rt.byteSliceGet(data, i), 0); }; const hex: Hex.Hex = { _0: rt.u32Mul(at(0) as rt.u32, 4097) }; const args2: rt.Fmt[] = [(f: rt.Formatter) => Hex.fmt$Display(hex, f), (f: rt.Formatter) => Hex.fmt$Debug(hex, f)]; put(out, rt.fmtFormat([args2[0], "|", rt.fmtSpec({ align: ">", width: 12 }, args2[0]), "|", rt.fmtSpec({ alternate: true }, args2[0]), "|", args2[1], "|", rt.fmtSpec({ align: ">", width: 6 }, args2[1]), "|", rt.fmtSpec({ alternate: true }, args2[1])])); + const args4: rt.Fmt[] = [(f: rt.Formatter) => Hex.fmt$Debug(hex, f), (f: rt.Formatter) => Hex.fmt$Binary(hex, f), (f: rt.Formatter) => Hex.fmt$Octal(hex, f), (f: rt.Formatter) => Hex.fmt$LowerExp(hex, f), (f: rt.Formatter) => Hex.fmt$UpperExp(hex, f)]; + put(out, rt.fmtFormat([rt.fmtSpec({ debugHex: "x" }, args4[0]), "|", rt.fmtSpec({ alternate: true }, args4[1]), "|", rt.fmtSpec({ align: ">", width: 8 }, args4[2]), "|", rt.fmtSpec({ precision: 2 }, args4[3]), "|", args4[4], "|", rt.fmtSpec({ plus: true, precision: 1 }, args4[0])])); put(out, rt.fmtToString((f: rt.Formatter) => Hex.fmt$Display(hex, f))); const arg = { _0: "pad" }; - const args4: rt.Fmt[] = [(f: rt.Formatter) => Padded.fmt$Display(arg, f)]; - put(out, rt.fmtFormat([args4[0], "|", rt.fmtSpec({ align: ">", width: 6 }, args4[0]), "|", rt.fmtSpec({ fill: "_", align: "^", width: 9 }, args4[0]), "|", rt.fmtSpec({ width: 30 }, args4[0]), "|"])); + const args6: rt.Fmt[] = [(f: rt.Formatter) => Padded.fmt$Display(arg, f)]; + put(out, rt.fmtFormat([args6[0], "|", rt.fmtSpec({ align: ">", width: 6 }, args6[0]), "|", rt.fmtSpec({ fill: "_", align: "^", width: 9 }, args6[0]), "|", rt.fmtSpec({ width: 30 }, args6[0]), "|"])); const manual: Manual.Manual = { id: at(1), list: [1, at(2) as rt.u16].slice() }; const empty: Manual.Manual = { id: 0, list: [] }; - const args6: rt.Fmt[] = [(f: rt.Formatter) => Manual.fmt$Debug(manual, f), (f: rt.Formatter) => Manual.fmt$Debug(empty, f)]; - put(out, rt.fmtFormat([args6[0], " ", rt.fmtSpec({ alternate: true }, args6[0]), " ", args6[1]])); + const args8: rt.Fmt[] = [(f: rt.Formatter) => Manual.fmt$Debug(manual, f), (f: rt.Formatter) => Manual.fmt$Debug(empty, f)]; + put(out, rt.fmtFormat([args8[0], " ", rt.fmtSpec({ alternate: true }, args8[0]), " ", args8[1]])); const seq: Seq.Seq = { _0: [{ _0: at(3), _1: 0 }, { _0: 1, _1: -1 }].slice() }; const none: Seq.Seq = { _0: [] }; - const args8: rt.Fmt[] = [(f: rt.Formatter) => Seq.fmt$Debug(seq, f), (f: rt.Formatter) => Seq.fmt$Debug(none, f)]; - put(out, rt.fmtFormat([args8[0], " ", rt.fmtSpec({ alternate: true }, args8[0]), " ", args8[1], " ", rt.fmtSpec({ alternate: true }, args8[1])])); - const _97: rt.u8 = at(4); + const args10: rt.Fmt[] = [(f: rt.Formatter) => Seq.fmt$Debug(seq, f), (f: rt.Formatter) => Seq.fmt$Debug(none, f)]; + put(out, rt.fmtFormat([args10[0], " ", rt.fmtSpec({ alternate: true }, args10[0]), " ", args10[1], " ", rt.fmtSpec({ alternate: true }, args10[1])])); + const _113: rt.u8 = at(4); if (!(rt.u8Rem(at(5), 2) === 0)) { - _100 = undefined; + _116 = undefined; } else { - _100 = at(5); + _116 = at(5); } - const arg2 = { _0: _97, _1: _100 }; - const args10: rt.Fmt[] = [(f: rt.Formatter) => Tup.fmt$Debug(arg2, f)]; - put(out, rt.fmtFormat([args10[0], " ", rt.fmtSpec({ alternate: true }, args10[0])])); + const arg2 = { _0: _113, _1: _116 }; + const args12: rt.Fmt[] = [(f: rt.Formatter) => Tup.fmt$Debug(arg2, f)]; + put(out, rt.fmtFormat([args12[0], " ", rt.fmtSpec({ alternate: true }, args12[0])])); const part = { _0: at(6) & (~1 & 0xff) }; - const args12: rt.Fmt[] = [(f: rt.Formatter) => Fails.fmt$Display(part, f)]; - put(out, rt.fmtFormat([args12[0], " ", rt.fmtSpec({ align: ">", width: 9 }, args12[0])])); - const _148: rt.u8 = at(7); - const _152: rt.u8 = at(8); - const args14: rt.Fmt[] = [(f: rt.Formatter) => rt.u8Display(_152, f), (f: rt.Formatter) => rt.u8Display(_148, f), (f: rt.Formatter) => rt.u8Display(_148, f), (f: rt.Formatter) => rt.fmtPad(f, "named")]; - put(out, rt.fmtFormat([args14[0], " ", args14[1], " ", args14[2], " named ", rt.fmtSpec({ align: ">", width: 5 }, args14[3])])); + const args14: rt.Fmt[] = [(f: rt.Formatter) => Fails.fmt$Display(part, f)]; + put(out, rt.fmtFormat([args14[0], " ", rt.fmtSpec({ align: ">", width: 9 }, args14[0])])); + const _164: rt.u8 = at(7); + const _168: rt.u8 = at(8); + const args16: rt.Fmt[] = [(f: rt.Formatter) => rt.u8Display(_168, f), (f: rt.Formatter) => rt.u8Display(_164, f), (f: rt.Formatter) => rt.u8Debug(_164, f), (f: rt.Formatter) => rt.fmtPad(f, "named")]; + put(out, rt.fmtFormat([args16[0], " ", args16[1], " ", args16[2], " named ", rt.fmtSpec({ align: ">", width: 5 }, args16[3])])); const log: rt.ByteVec = new rt.ByteVec(); - const _171: rt.u8 = at(9); - const _169: rt.u8 = note(log, _171); - const _178: rt.u8 = at(10); - const _175: boolean = note(log, _178) === 3; - const _182: rt.usize = log.length; - const args16: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtBool(_175, f), (f: rt.Formatter) => rt.u8Display(_169, f), (f: rt.Formatter) => rt.u8Display(_169, f), (f: rt.Formatter) => rt.usizeDisplay(_182, f)]; - put(out, rt.fmtFormat([args16[0], " ", args16[1], " ", args16[2], " ", args16[3], " ", args16[1]])); - const _202: Noted.Noted = { _0: at(11) }; - const _206: Noted.Noted = { _0: 2 }; - const args18: rt.Fmt[] = [(f: rt.Formatter) => Noted.fmt$Display(_202, f), (f: rt.Formatter) => Noted.fmt$Display(_206, f)]; - put(out, rt.fmtFormat([args18[0], "|", rt.fmtSpec({ align: ">", width: 6 }, args18[1])])); + const _187: rt.u8 = at(9); + const _185: rt.u8 = note(log, _187); + const _194: rt.u8 = at(10); + const _191: boolean = note(log, _194) === 3; + const _198: rt.usize = log.length; + const args18: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtBool(_191, f), (f: rt.Formatter) => rt.u8Display(_185, f), (f: rt.Formatter) => rt.u8Debug(_185, f), (f: rt.Formatter) => rt.usizeDisplay(_198, f)]; + put(out, rt.fmtFormat([args18[0], " ", args18[1], " ", args18[2], " ", args18[3], " ", args18[1]])); + const _218: Noted.Noted = { _0: at(11) }; + const _222: Noted.Noted = { _0: 2 }; + const args20: rt.Fmt[] = [(f: rt.Formatter) => Noted.fmt$Display(_218, f), (f: rt.Formatter) => Noted.fmt$Display(_222, f)]; + put(out, rt.fmtFormat([args20[0], "|", rt.fmtSpec({ align: ">", width: 6 }, args20[1])])); if (!((data.length === 0))) { put(out, logged(log, data)); } - const _225: rt.u8 = at(13); - const part2 = note(log, _225); - const args20: rt.Fmt[] = [(f: rt.Formatter) => rt.u8Display(part2, f)]; - const once: string = rt.fmtFormat([args20[0]]); - const _241: rt.usize = log.length; - const args22: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, once), (f: rt.Formatter) => rt.usizeDisplay(_241, f)]; - put(out, rt.fmtFormat([args22[0], " ", args22[1]])); + const _241: rt.u8 = at(13); + const part2 = note(log, _241); + const args22: rt.Fmt[] = [(f: rt.Formatter) => rt.u8Debug(part2, f)]; + const once: string = rt.fmtFormat([args22[0]]); + const _257: rt.usize = log.length; + const args24: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, once), (f: rt.Formatter) => rt.usizeDisplay(_257, f)]; + put(out, rt.fmtFormat([args24[0], " ", args24[1]])); rt.byteVecExtendFromSlice(out, rt.byteVecSlice(log)); if (at(12) > 250) { - const _261: rt.u8 = at(12); - const _259: rt.u8 = note(log, _261); - const _265: rt.usize = log.length; - const args24: rt.Fmt[] = [(f: rt.Formatter) => rt.u8Display(_259, f), (f: rt.Formatter) => rt.usizeDisplay(_265, f)]; - rt.panicFmt([args24[0], " ", args24[1]]); + const _277: rt.u8 = at(12); + const _275: rt.u8 = note(log, _277); + const _281: rt.usize = log.length; + const args26: rt.Fmt[] = [(f: rt.Formatter) => rt.u8Display(_275, f), (f: rt.Formatter) => rt.usizeDisplay(_281, f)]; + rt.panicFmt([args26[0], " ", args26[1]]); + } +} + +/** + * Widths and precisions from arguments, by position and by name, and one past + * `u16::MAX`, which panics. + */ +export function counts(data: rt.ByteSlice, out: rt.ByteVec): void { + const at: (a0: rt.usize) => rt.u8 = (i: rt.usize): rt.u8 => { + return unwrapOr$Option_u8(rt.byteSliceGet(data, i), 0); + }; + const _6: [rt.usize, rt.usize] = [rt.u8Rem(at(0), 24) as rt.usize, rt.u8Rem(at(1), 12) as rt.usize]; + const w: rt.usize = _6[0]; + const p: rt.usize = _6[1]; + const data2: rt.ByteSlice = rt.byteSliceRange(data, rt.min(data.length, 2)); + const buf: Uint8Array = rt.bytes(8); + const n: rt.usize = rt.min(data2.length, rt.byteSliceFrom(buf).length); + rt.byteSliceCopyFromSlice(rt.byteSliceRange(rt.byteSliceFrom(buf), 0, n), rt.byteSliceRange(data2, 0, n)); + const v: rt.i64 = rt.i64FromBeBytes(buf); + const _39: rt.usize = rt.usizeRem(at(3) as rt.usize, ["", "a", "héllo", "日本語", "tab\tnew\nline\r", "quote\"back\\slash'", "\u0000\u0001\u001f", "€Ÿ ­", "é", "‍ᅟ\u2028 ", "͸􏿽", "😀 🇦", "゙゚ン", "{}"].length); + if (!(_39 < 14)) { + rt.panic("index out of bounds: the len is " + 14 + " but the index is " + _39); + } + const s: string = ["", "a", "héllo", "日本語", "tab\tnew\nline\r", "quote\"back\\slash'", "\u0000\u0001\u001f", "€Ÿ ­", "é", "‍ᅟ\u2028 ", "͸􏿽", "😀 🇦", "゙゚ン", "{}"][_39]; + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.i64Display(v, f), rt.fmtCount(w), (f: rt.Formatter) => rt.i64LowerExp(v, f), rt.fmtCount(p), (f: rt.Formatter) => rt.fmtPad(f, s), (f: rt.Formatter) => rt.fmtPad(f, s), rt.fmtCount(p), (f: rt.Formatter) => rt.usizeDisplay(w, f), rt.fmtCount(w), (f: rt.Formatter) => rt.fmtStr(s, f)]; + put(out, rt.fmtFormat([rt.fmtSpec({ width: rt.fmtCountOf(args2[1]) }, args2[0]), "|", rt.fmtSpec({ align: "<", width: rt.fmtCountOf(args2[1]) }, args2[2]), "|", rt.fmtSpec({ plus: true, zero: true, width: rt.fmtCountOf(args2[1]), precision: rt.fmtCountOf(args2[3]) }, args2[2]), "|", rt.fmtSpec({ precision: rt.fmtCountOf(args2[3]) }, args2[4]), "|", rt.fmtSpec({ align: "^", width: rt.fmtCountOf(args2[1]), precision: rt.fmtCountOf(args2[3]) }, args2[4]), "|", rt.fmtSpec({ precision: rt.fmtCountOf(args2[6]) }, args2[5]), "|", rt.fmtSpec({ align: ">", width: rt.fmtCountOf(args2[6]) }, args2[7]), "|", rt.fmtSpec({ width: rt.fmtCountOf(args2[8]), precision: rt.fmtCountOf(args2[6]) }, args2[5]), "|", rt.fmtSpec({ align: ">", width: rt.fmtCountOf(args2[3]) }, args2[9])])); + const log: rt.ByteVec = new rt.ByteVec(); + const _87: rt.u8 = at(4); + const _85: rt.u8 = note(log, _87); + const _91: rt.usize = note(log, 6) as rt.usize; + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.u8Display(_85, f), rt.fmtCount(_91), (f: rt.Formatter) => rt.fmtPad(f, s)]; + put(out, rt.fmtFormat([rt.fmtSpec({ align: ">", width: rt.fmtCountOf(args4[1]) }, args4[0]), "|", rt.fmtSpec({ precision: rt.fmtCountOf(args4[1]) }, args4[2])])); + rt.byteVecExtendFromSlice(out, rt.byteVecSlice(log)); + const big: rt.usize = rt.usizeAdd(65535 as rt.usize, rt.u8Rem(at(5), 2) as rt.usize); + const args6: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, s), rt.fmtCount(big)]; + put(out, rt.fmtFormat([rt.fmtSpec({ precision: rt.fmtCountOf(args6[1]) }, args6[0]), "|"])); +} + +/** `{:e}` at each rounding: below, above, and ties to even, which may carry a digit. */ +export function rounding(out: rt.ByteVec): void { + const iter: rt.Iter = rt.iterSlice([0, 5, 15, 25, 125, 135, 994, 995, 999, 1000, 1250000, 4294967295]); + while (true) { + const _5: rt.u32 | rt.Done = iter.next(); + if (_5 === rt.DONE) { + break; + } + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.u32LowerExp(_5, f)]; + put(out, rt.fmtFormat([rt.fmtSpec({ precision: 0 }, args2[0]), " ", rt.fmtSpec({ precision: 1 }, args2[0]), " ", rt.fmtSpec({ precision: 2 }, args2[0]), " ", args2[0]])); } + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.u128LowerExp({ hi: 0xffffffff, w2: 0xffffffff, w1: 0xffffffff, lo: 0xffffffff } as rt.u128, f), (f: rt.Formatter) => rt.i128LowerExp({ hi: -0x80000000, w2: 0, w1: 0, lo: 0 } as rt.i128, f), (f: rt.Formatter) => rt.i64UpperExp({ hi: -0x80000000, lo: 0 } as rt.i64, f)]; + put(out, rt.fmtFormat([rt.fmtSpec({ precision: 0 }, args4[0]), " ", args4[1], " ", rt.fmtSpec({ precision: 3 }, args4[2])])); } /** Panics, each with the message native Rust formats. */ @@ -364,7 +475,7 @@ export function panics(kind: rt.u8, rest: rt.ByteSlice, out: rt.ByteVec): void { const n: rt.u8 = unwrapOr$Option_u8(rt.byteSliceFirst(rest), 0); const _7: rt.u8 = rt.u8Rem(kind, 20); if (_7 === 0) { - const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.u8Display(n, f), (f: rt.Formatter) => rt.fmtList(rt.byteSliceView(rest), f, rt.u8Display)]; + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.u8Display(n, f), (f: rt.Formatter) => rt.fmtList(rt.byteSliceView(rest), f, rt.u8Debug)]; rt.panicFmt(["bad ", args2[0], ": ", args2[1]]); } else if (_7 === 1) { const _23: Hex.Hex = { _0: n as rt.u32 }; @@ -382,7 +493,7 @@ export function panics(kind: rt.u8, rest: rt.ByteSlice, out: rt.ByteVec): void { } } else if (_7 === 4) { if (!(n === 7)) { - rt.assertFailed("==", (f: rt.Formatter) => rt.u8Display(n, f), (f: rt.Formatter) => rt.u8Display(7, f), undefined as rt.Arguments | undefined); + rt.assertFailed("==", (f: rt.Formatter) => rt.u8Debug(n, f), (f: rt.Formatter) => rt.u8Debug(7, f), undefined as rt.Arguments | undefined); } } else if (_7 === 5) { const _58: Pair.Pair = { _0: n, _1: 1 }; @@ -395,7 +506,7 @@ export function panics(kind: rt.u8, rest: rt.ByteSlice, out: rt.ByteVec): void { } } else if (_7 === 6) { if (!(n === 9)) { - rt.assertFailed("==", (f: rt.Formatter) => rt.u8Display(n, f), (f: rt.Formatter) => rt.u8Display(9, f), ["with context"]); + rt.assertFailed("==", (f: rt.Formatter) => rt.u8Debug(n, f), (f: rt.Formatter) => rt.u8Debug(9, f), ["with context"]); } } else if (_7 === 7) { if (rt.u8Rem(n, 2) === 0) { @@ -439,13 +550,13 @@ export function panics(kind: rt.u8, rest: rt.ByteSlice, out: rt.ByteVec): void { const end: rt.usize = _173[1]; const _189: rt.ByteSlice = rt.byteSliceRange(rest, start); const _193: rt.ByteSlice = rt.byteSliceRange(rest, start, end); - const args16: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(rt.byteSliceView(_189), f, rt.u8Display), (f: rt.Formatter) => rt.fmtList(rt.byteSliceView(_193), f, rt.u8Display)]; + const args16: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(rt.byteSliceView(_189), f, rt.u8Debug), (f: rt.Formatter) => rt.fmtList(rt.byteSliceView(_193), f, rt.u8Debug)]; put(out, rt.fmtFormat([args16[0], " ", args16[1]])); } else if (_7 === 15) { const buf: Uint8Array = rt.bytes(3); rt.byteSliceCopyFromSlice(rt.byteSliceFrom(buf), rt.byteSliceRange(rest, 0, rt.min(rest.length, 4))); const part6 = rt.byteSliceFrom(buf); - const args18: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(rt.byteSliceView(part6), f, rt.u8Display)]; + const args18: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(rt.byteSliceView(part6), f, rt.u8Debug)]; put(out, rt.fmtFormat([args18[0]])); } else if (_7 === 16) { const _221: rt.Result = rt.stringFromUtf8(rt.byteSliceToByteVec(rest)); @@ -463,7 +574,7 @@ export function panics(kind: rt.u8, rest: rt.ByteSlice, out: rt.ByteVec): void { const dest: rt.usize = rt.usizeRem(unwrapOr$Option_u8(rt.byteSliceGet(rest, 1), 0) as rt.usize, 4); rt.byteSliceCopyWithin(rt.byteSliceFrom(buf2), part2, part3, dest); const part4 = rt.byteSliceFrom(buf2); - const args20: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(rt.byteSliceView(part4), f, rt.u8Display)]; + const args20: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(rt.byteSliceView(part4), f, rt.u8Debug)]; put(out, rt.fmtFormat([args20[0]])); } else if (_7 === 18) { const _271: rt.usize = rt.u8Rem(n, 8) as rt.usize; @@ -476,7 +587,7 @@ export function panics(kind: rt.u8, rest: rt.ByteSlice, out: rt.ByteVec): void { } else { r5 = rt.Err(n); } - const part = rt.resultUnwrapErr(r5, rt.u8Display); + const part = rt.resultUnwrapErr(r5, rt.u8Debug); const args22: rt.Fmt[] = [(f: rt.Formatter) => rt.u8Display(part, f)]; put(out, rt.fmtFormat([args22[0]])); } diff --git a/ts/fixtures/lang/expected/generics.Either.ts b/ts/fixtures/lang/expected/generics.Either.ts index a1e338ba8..bf8c2a080 100644 --- a/ts/fixtures/lang/expected/generics.Either.ts +++ b/ts/fixtures/lang/expected/generics.Either.ts @@ -13,7 +13,7 @@ export function fmt$Debug_Point_u8(self: Either, f: rt.Forma if (self.tag === "Right") { const _9: string = "Right"; const _10: string = "value"; - const _11: rt.Fmt = (f: rt.Formatter) => rt.u8Display(self.value, f); + const _11: rt.Fmt = (f: rt.Formatter) => rt.u8Debug(self.value, f); return rt.debugStructFinish(rt.debugStructField(rt.fmtDebugStruct(f, _9), _10, _11)); } return rt.fmtWriteStr(f, "Neither"); @@ -22,7 +22,7 @@ export function fmt$Debug_Point_u8(self: Either, f: rt.Forma export function fmt$Debug_u8_Point(self: Either, f: rt.Formatter): rt.Result { if (self.tag === "Left") { const _5: string = "Left"; - const _6: rt.Fmt = (f: rt.Formatter) => rt.u8Display(self._0, f); + const _6: rt.Fmt = (f: rt.Formatter) => rt.u8Debug(self._0, f); return rt.debugTupleFinish(rt.debugTupleField(rt.fmtDebugTuple(f, _5), _6)); } if (self.tag === "Right") { @@ -37,13 +37,13 @@ export function fmt$Debug_u8_Point(self: Either, f: rt.Forma export function fmt$Debug_u8_u16(self: Either, f: rt.Formatter): rt.Result { if (self.tag === "Left") { const _5: string = "Left"; - const _6: rt.Fmt = (f: rt.Formatter) => rt.u8Display(self._0, f); + const _6: rt.Fmt = (f: rt.Formatter) => rt.u8Debug(self._0, f); return rt.debugTupleFinish(rt.debugTupleField(rt.fmtDebugTuple(f, _5), _6)); } if (self.tag === "Right") { const _9: string = "Right"; const _10: string = "value"; - const _11: rt.Fmt = (f: rt.Formatter) => rt.u16Display(self.value, f); + const _11: rt.Fmt = (f: rt.Formatter) => rt.u16Debug(self.value, f); return rt.debugStructFinish(rt.debugStructField(rt.fmtDebugStruct(f, _9), _10, _11)); } return rt.fmtWriteStr(f, "Neither"); diff --git a/ts/fixtures/lang/expected/generics.Wrap.ts b/ts/fixtures/lang/expected/generics.Wrap.ts index e16db3957..3c5cc5172 100644 --- a/ts/fixtures/lang/expected/generics.Wrap.ts +++ b/ts/fixtures/lang/expected/generics.Wrap.ts @@ -9,9 +9,9 @@ import * as Shape from "./shapes.Shape.ts"; export function fmt$Debug_Option_u8(self: Wrap, f: rt.Formatter): rt.Result { const _3: string = "Wrap"; const _4: string = "value"; - const _5: rt.Fmt = (f: rt.Formatter) => rt.fmtOption(self.value, f, rt.u8Display); + const _5: rt.Fmt = (f: rt.Formatter) => rt.fmtOption(self.value, f, rt.u8Debug); const _7: string = "count"; - const _8: rt.Fmt = (f: rt.Formatter) => rt.u8Display(self.count, f); + const _8: rt.Fmt = (f: rt.Formatter) => rt.u8Debug(self.count, f); return rt.debugStructFinish(rt.debugStructField(rt.debugStructField(rt.fmtDebugStruct(f, _3), _4, _5), _7, _8)); } @@ -20,7 +20,7 @@ export function fmt$Debug_Pair(self: Wrap, f: rt.Formatter): rt.Resul const _4: string = "value"; const _5: rt.Fmt = (f: rt.Formatter) => Pair.fmt$Debug(self.value, f); const _7: string = "count"; - const _8: rt.Fmt = (f: rt.Formatter) => rt.u8Display(self.count, f); + const _8: rt.Fmt = (f: rt.Formatter) => rt.u8Debug(self.count, f); return rt.debugStructFinish(rt.debugStructField(rt.debugStructField(rt.fmtDebugStruct(f, _3), _4, _5), _7, _8)); } @@ -29,16 +29,16 @@ export function fmt$Debug_Point(self: Wrap, f: rt.Formatter): rt.Re const _4: string = "value"; const _5: rt.Fmt = (f: rt.Formatter) => Point.fmt$Debug(self.value, f); const _7: string = "count"; - const _8: rt.Fmt = (f: rt.Formatter) => rt.u8Display(self.count, f); + const _8: rt.Fmt = (f: rt.Formatter) => rt.u8Debug(self.count, f); return rt.debugStructFinish(rt.debugStructField(rt.debugStructField(rt.fmtDebugStruct(f, _3), _4, _5), _7, _8)); } export function fmt$Debug_Result_u8_Shape(self: Wrap>, f: rt.Formatter): rt.Result { const _3: string = "Wrap"; const _4: string = "value"; - const _5: rt.Fmt = (f: rt.Formatter) => rt.fmtResult(self.value, f, rt.u8Display, (value: Shape.Shape, f: rt.Formatter) => Shape.fmt$Debug(value, f)); + const _5: rt.Fmt = (f: rt.Formatter) => rt.fmtResult(self.value, f, rt.u8Debug, (value: Shape.Shape, f: rt.Formatter) => Shape.fmt$Debug(value, f)); const _7: string = "count"; - const _8: rt.Fmt = (f: rt.Formatter) => rt.u8Display(self.count, f); + const _8: rt.Fmt = (f: rt.Formatter) => rt.u8Debug(self.count, f); return rt.debugStructFinish(rt.debugStructField(rt.debugStructField(rt.fmtDebugStruct(f, _3), _4, _5), _7, _8)); } @@ -47,16 +47,16 @@ export function fmt$Debug_Shape(self: Wrap, f: rt.Formatter): rt.Re const _4: string = "value"; const _5: rt.Fmt = (f: rt.Formatter) => Shape.fmt$Debug(self.value, f); const _7: string = "count"; - const _8: rt.Fmt = (f: rt.Formatter) => rt.u8Display(self.count, f); + const _8: rt.Fmt = (f: rt.Formatter) => rt.u8Debug(self.count, f); return rt.debugStructFinish(rt.debugStructField(rt.debugStructField(rt.fmtDebugStruct(f, _3), _4, _5), _7, _8)); } export function fmt$Debug_Vec_u16(self: Wrap, f: rt.Formatter): rt.Result { const _3: string = "Wrap"; const _4: string = "value"; - const _5: rt.Fmt = (f: rt.Formatter) => rt.fmtList(self.value, f, rt.u16Display); + const _5: rt.Fmt = (f: rt.Formatter) => rt.fmtList(self.value, f, rt.u16Debug); const _7: string = "count"; - const _8: rt.Fmt = (f: rt.Formatter) => rt.u8Display(self.count, f); + const _8: rt.Fmt = (f: rt.Formatter) => rt.u8Debug(self.count, f); return rt.debugStructFinish(rt.debugStructField(rt.debugStructField(rt.fmtDebugStruct(f, _3), _4, _5), _7, _8)); } @@ -65,25 +65,25 @@ export function fmt$Debug_Wrap_Pair(self: Wrap>, f: rt.Formatter const _4: string = "value"; const _5: rt.Fmt = (f: rt.Formatter) => fmt$Debug_Pair(self.value, f); const _7: string = "count"; - const _8: rt.Fmt = (f: rt.Formatter) => rt.u8Display(self.count, f); + const _8: rt.Fmt = (f: rt.Formatter) => rt.u8Debug(self.count, f); return rt.debugStructFinish(rt.debugStructField(rt.debugStructField(rt.fmtDebugStruct(f, _3), _4, _5), _7, _8)); } export function fmt$Debug_i16(self: Wrap, f: rt.Formatter): rt.Result { const _3: string = "Wrap"; const _4: string = "value"; - const _5: rt.Fmt = (f: rt.Formatter) => rt.i16Display(self.value, f); + const _5: rt.Fmt = (f: rt.Formatter) => rt.i16Debug(self.value, f); const _7: string = "count"; - const _8: rt.Fmt = (f: rt.Formatter) => rt.u8Display(self.count, f); + const _8: rt.Fmt = (f: rt.Formatter) => rt.u8Debug(self.count, f); return rt.debugStructFinish(rt.debugStructField(rt.debugStructField(rt.fmtDebugStruct(f, _3), _4, _5), _7, _8)); } export function fmt$Debug_u8(self: Wrap, f: rt.Formatter): rt.Result { const _3: string = "Wrap"; const _4: string = "value"; - const _5: rt.Fmt = (f: rt.Formatter) => rt.u8Display(self.value, f); + const _5: rt.Fmt = (f: rt.Formatter) => rt.u8Debug(self.value, f); const _7: string = "count"; - const _8: rt.Fmt = (f: rt.Formatter) => rt.u8Display(self.count, f); + const _8: rt.Fmt = (f: rt.Formatter) => rt.u8Debug(self.count, f); return rt.debugStructFinish(rt.debugStructField(rt.debugStructField(rt.fmtDebugStruct(f, _3), _4, _5), _7, _8)); } diff --git a/ts/fixtures/lang/expected/generics.ts b/ts/fixtures/lang/expected/generics.ts index 2f5330e19..3edcdde70 100644 --- a/ts/fixtures/lang/expected/generics.ts +++ b/ts/fixtures/lang/expected/generics.ts @@ -55,7 +55,7 @@ export function methods(data: rt.ByteSlice, out: rt.ByteVec): void { const flipped: Either.Either = Either.flip$u8_Point(either); const _153: rt.u8 | undefined = Either.left$u8_Point(either); const _156: Point.Point | undefined = Either.left$Point_u8(flipped); - const args8: rt.Fmt[] = [(f: rt.Formatter) => Either.fmt$Debug_u8_Point(either, f), (f: rt.Formatter) => Either.fmt$Debug_Point_u8(flipped, f), (f: rt.Formatter) => rt.fmtOption(_153, f, rt.u8Display), (f: rt.Formatter) => rt.fmtOption(_156, f, (value: Point.Point, f: rt.Formatter) => Point.fmt$Debug(value, f))]; + const args8: rt.Fmt[] = [(f: rt.Formatter) => Either.fmt$Debug_u8_Point(either, f), (f: rt.Formatter) => Either.fmt$Debug_Point_u8(flipped, f), (f: rt.Formatter) => rt.fmtOption(_153, f, rt.u8Debug), (f: rt.Formatter) => rt.fmtOption(_156, f, (value: Point.Point, f: rt.Formatter) => Point.fmt$Debug(value, f))]; put(out, rt.fmtFormat([args8[0], " ", rt.fmtSpec({ alternate: true }, args8[1]), " ", args8[2], " ", args8[3]])); } const list: Wrap.Wrap = new Wrap.Wrap({ value: [], count: 1 }); @@ -66,7 +66,7 @@ export function methods(data: rt.ByteSlice, out: rt.ByteVec): void { const some: Wrap.Wrap = Wrap.new$Option_u8(rt.byteSliceGet(data, 11)); const err: Wrap.Wrap> = new Wrap.Wrap({ value: rt.Err({ tag: "Dot" } as Shape.Shape), count: 2 }); const _193: rt.u8 = unwrapOr$Option_u8(Wrap.get$Option_u8(none), some.count); - const args10: rt.Fmt[] = [(f: rt.Formatter) => Wrap.fmt$Debug_Vec_u16(list, f), (f: rt.Formatter) => Wrap.fmt$Debug_Option_u8(none, f), (f: rt.Formatter) => Wrap.fmt$Debug_Option_u8(some, f), (f: rt.Formatter) => Wrap.fmt$Debug_Result_u8_Shape(err, f), (f: rt.Formatter) => rt.u8Display(_193, f)]; + const args10: rt.Fmt[] = [(f: rt.Formatter) => Wrap.fmt$Debug_Vec_u16(list, f), (f: rt.Formatter) => Wrap.fmt$Debug_Option_u8(none, f), (f: rt.Formatter) => Wrap.fmt$Debug_Option_u8(some, f), (f: rt.Formatter) => Wrap.fmt$Debug_Result_u8_Shape(err, f), (f: rt.Formatter) => rt.u8Debug(_193, f)]; put(out, rt.fmtFormat([args10[0], " ", args10[1], " ", args10[2], " ", args10[3], " ", args10[4]])); const tagged: Tagged.Tagged, rt.i16> = new Tagged.Tagged({ key: { tag: "Right", value: 500 } as Either.Either, inner: Wrap.new$i16(rt.i16Sub(at(8) as rt.i16, 100)), all: [Wrap.new$i16(-1), Wrap.new$i16(at(9) as rt.i16)].map(copy$Wrap_i16) }); const _237: Wrap.Wrap | undefined = Tagged.first$Either_u8_u16_i16(tagged); diff --git a/ts/fixtures/lang/expected/harness.ts b/ts/fixtures/lang/expected/harness.ts index 675abdb19..6c59f3c9a 100644 --- a/ts/fixtures/lang/expected/harness.ts +++ b/ts/fixtures/lang/expected/harness.ts @@ -7,7 +7,7 @@ import { hashMaps, sets, btreeMaps, deques, vecs, stores } from "./collections.t import { combinators } from "./combinators.ts"; import { cows } from "./cows.ts"; import { durations } from "./durations.ts"; -import { ints, strings, derived, written, panics } from "./fmt.ts"; +import { ints, strings, derived, written, counts, rounding, panics } from "./fmt.ts"; import { methods } from "./generics.ts"; import { u8Op, u16Op, u32Op, u64Op, u128Op, usizeOp, i8Op, i16Op, i32Op, i64Op, i128Op, isizeOp, i8Neg, i16Neg, i32Neg, i64Neg, i128Neg, isizeNeg, cast, convert } from "./ints.ts"; import { adaptors, consumers, skips, ranges, options, own, values } from "./iters.ts"; @@ -26,7 +26,7 @@ export function run(input: rt.ByteSlice): rt.ByteVec { const _10: [rt.u8, rt.u8] = [input.data[input.start], input.data[input.start + 1]]; const op: rt.u8 = _10[0]; const kind: rt.u8 = _10[1]; - const _14: rt.u8 = rt.u8Rem(op, 52); + const _14: rt.u8 = rt.u8Rem(op, 54); if (_14 === 0) { u8Op(kind, new rt.ByteSlice(input.data, input.start + 2, input.length - 2), out); } else if (_14 === 1) { @@ -146,6 +146,10 @@ export function run(input: rt.ByteSlice): rt.ByteVec { splits(kind, new rt.ByteSlice(input.data, input.start + 2, input.length - 2), out); } else if (_14 === 50) { refs(new rt.ByteSlice(input.data, input.start + 2, input.length - 2), out); + } else if (_14 === 51) { + counts(new rt.ByteSlice(input.data, input.start + 2, input.length - 2), out); + } else if (_14 === 52) { + rounding(out); } else { skips(kind, new rt.ByteSlice(input.data, input.start + 2, input.length - 2), out); } diff --git a/ts/fixtures/lang/expected/iters.Doubled.ts b/ts/fixtures/lang/expected/iters.Doubled.ts index a2b191f33..62273178c 100644 --- a/ts/fixtures/lang/expected/iters.Doubled.ts +++ b/ts/fixtures/lang/expected/iters.Doubled.ts @@ -12,7 +12,7 @@ export function fmt$Debug(self: Doubled, f: rt.Formatter): rt.Result = rt.iterMap(rt.iterSlice(rt.byteSliceView(self._0)), (_2: rt.u8): rt.u16 => { return rt.u16Mul(_2 as rt.u16, 2); }); - return rt.debugListFinish(rt.debugListEntries(_5, _6, rt.u16Display)); + return rt.debugListFinish(rt.debugListEntries(_5, _6, rt.u16Debug)); } //# sourceMappingURL=iters.Doubled.ts.map diff --git a/ts/fixtures/lang/expected/refs.ts b/ts/fixtures/lang/expected/refs.ts index 0ab5fc16d..5318f70a2 100644 --- a/ts/fixtures/lang/expected/refs.ts +++ b/ts/fixtures/lang/expected/refs.ts @@ -133,7 +133,7 @@ export function readThrough(a: rt.Place, b: rt.Place, out: rt.By rt.byteVecPush(out, a.v === b.v ? 1 : 0); rt.byteVecPush(out, a.v < b.v ? 1 : 0); rt.byteVecPush(out, rt.cmp(a.v, b.v) & 0xff); - const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(a.v, f), (f: rt.Formatter) => rt.u32Display(b.v, f)]; + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(a.v, f), (f: rt.Formatter) => rt.u32Debug(b.v, f)]; rt.byteVecExtendFromSlice(out, rt.stringAsBytes(rt.fmtFormat([args2[0], "|", args2[1]]))); } diff --git a/ts/fixtures/lang/expected/shapes.Moved.ts b/ts/fixtures/lang/expected/shapes.Moved.ts index 404118024..82183e7a2 100644 --- a/ts/fixtures/lang/expected/shapes.Moved.ts +++ b/ts/fixtures/lang/expected/shapes.Moved.ts @@ -4,8 +4,8 @@ import * as rt from "./rt.ts"; export function fmt$Debug(self: Moved, f: rt.Formatter): rt.Result { const _3: string = "Moved"; - const _4: rt.Fmt = (f: rt.Formatter) => rt.u8Display(self._0, f); - const _6: rt.Fmt = (f: rt.Formatter) => rt.u16Display(self._1, f); + const _4: rt.Fmt = (f: rt.Formatter) => rt.u8Debug(self._0, f); + const _6: rt.Fmt = (f: rt.Formatter) => rt.u16Debug(self._1, f); return rt.debugTupleFinish(rt.debugTupleField(rt.debugTupleField(rt.fmtDebugTuple(f, _3), _4), _6)); } diff --git a/ts/fixtures/lang/expected/shapes.Point.ts b/ts/fixtures/lang/expected/shapes.Point.ts index e8ec4a997..9f06b7273 100644 --- a/ts/fixtures/lang/expected/shapes.Point.ts +++ b/ts/fixtures/lang/expected/shapes.Point.ts @@ -6,9 +6,9 @@ import { copy$Point } from "./lib.ts"; export function fmt$Debug(self: Point, f: rt.Formatter): rt.Result { const _3: string = "Point"; const _4: string = "x"; - const _5: rt.Fmt = (f: rt.Formatter) => rt.i32Display(self.x, f); + const _5: rt.Fmt = (f: rt.Formatter) => rt.i32Debug(self.x, f); const _7: string = "y"; - const _8: rt.Fmt = (f: rt.Formatter) => rt.i32Display(self.y, f); + const _8: rt.Fmt = (f: rt.Formatter) => rt.i32Debug(self.y, f); return rt.debugStructFinish(rt.debugStructField(rt.debugStructField(rt.fmtDebugStruct(f, _3), _4, _5), _7, _8)); } diff --git a/ts/fixtures/lang/expected/shapes.Shape.ts b/ts/fixtures/lang/expected/shapes.Shape.ts index c28eddb8d..fbbc1905d 100644 --- a/ts/fixtures/lang/expected/shapes.Shape.ts +++ b/ts/fixtures/lang/expected/shapes.Shape.ts @@ -17,9 +17,9 @@ export function fmt$Debug(self: Shape, f: rt.Formatter): rt.Result Point.fmt$Debug(self.corner, f); const _17: string = "width"; - const _18: rt.Fmt = (f: rt.Formatter) => rt.u16Display(self.width, f); + const _18: rt.Fmt = (f: rt.Formatter) => rt.u16Debug(self.width, f); const _19: string = "height"; - const _20: rt.Fmt = (f: rt.Formatter) => rt.u16Display(self.height, f); + const _20: rt.Fmt = (f: rt.Formatter) => rt.u16Debug(self.height, f); return rt.debugStructFinish(rt.debugStructField(rt.debugStructField(rt.debugStructField(rt.fmtDebugStruct(f, _14), _15, _16), _17, _18), _19, _20)); } diff --git a/ts/fixtures/lang/expected/shapes.ts b/ts/fixtures/lang/expected/shapes.ts index 3288bdbff..6dee5b7b5 100644 --- a/ts/fixtures/lang/expected/shapes.ts +++ b/ts/fixtures/lang/expected/shapes.ts @@ -166,12 +166,12 @@ export function copies(data: rt.ByteSlice, out: rt.ByteVec): void { return m._0; })))); const res: rt.Result = rt.Ok(p); - const first: Point.Point = copy$Point(rt.resultUnwrap(res, rt.u8Display)); + const first: Point.Point = copy$Point(rt.resultUnwrap(res, rt.u8Debug)); first.x = 2; const fail: rt.Result = rt.Err(copy$Point(q)); - const err: Point.Point = copy$Point(rt.resultUnwrapErr(fail, rt.u8Display)); + const err: Point.Point = copy$Point(rt.resultUnwrapErr(fail, rt.u8Debug)); err.y = 3; - rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(Uint8Array.of(first.x & 0xff, rt.resultUnwrap(res, rt.u8Display).x & 0xff, err.y & 0xff, rt.resultUnwrapErr(fail, rt.u8Display).y & 0xff))); + rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(Uint8Array.of(first.x & 0xff, rt.resultUnwrap(res, rt.u8Debug).x & 0xff, err.y & 0xff, rt.resultUnwrapErr(fail, rt.u8Debug).y & 0xff))); const shape_: Shape.Shape = copy$Shape(shape(data)); const before: Shape.Shape = copy$Shape(shape_); if (shape_.tag !== "Dot") { @@ -581,7 +581,7 @@ export function order(data: rt.ByteSlice, out: rt.ByteVec): void { const _87: rt.usize = rt.usizeDiv(rt.min(mark(out, 15), len), 2); const _103: rt.usize = sum; const _82: rt.ByteSlice = rt.byteSliceRange(_83, _87, _85); - const args2: rt.Fmt[] = [(f: rt.Formatter) => Shape.fmt$Debug(rect, f), (f: rt.Formatter) => Shape.fmt$Debug(line, f), (f: rt.Formatter) => Pair.fmt$Debug(pair, f), (f: rt.Formatter) => Point.fmt$Debug(read, f), (f: rt.Formatter) => Moved.fmt$Debug(updated, f), (f: rt.Formatter) => Shape.fmt$Debug(taken, f), (f: rt.Formatter) => rt.usizeDisplay(_64, f), (f: rt.Formatter) => rt.usizeDisplay(_63, f), (f: rt.Formatter) => rt.usizeDisplay(_103, f), (f: rt.Formatter) => rt.fmtList(rt.byteSliceView(_82), f, rt.u8Display)]; + const args2: rt.Fmt[] = [(f: rt.Formatter) => Shape.fmt$Debug(rect, f), (f: rt.Formatter) => Shape.fmt$Debug(line, f), (f: rt.Formatter) => Pair.fmt$Debug(pair, f), (f: rt.Formatter) => Point.fmt$Debug(read, f), (f: rt.Formatter) => Moved.fmt$Debug(updated, f), (f: rt.Formatter) => Shape.fmt$Debug(taken, f), (f: rt.Formatter) => rt.usizeDisplay(_64, f), (f: rt.Formatter) => rt.usizeDisplay(_63, f), (f: rt.Formatter) => rt.usizeDisplay(_103, f), (f: rt.Formatter) => rt.fmtList(rt.byteSliceView(_82), f, rt.u8Debug)]; rt.byteVecExtendFromSlice(out, rt.stringAsBytes(rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4], " ", args2[5], " ", args2[6], " ", args2[7], " ", args2[8], " ", args2[9]]))); const _125: rt.usize = mark(out, 16); const _127: rt.usize = out.length; @@ -1364,7 +1364,7 @@ export function patterns(data: rt.ByteSlice, out: rt.ByteVec): void { const parsed: rt.Result = rt.Ok(data.length & 0xff); const a2: rt.u8 = (parsed as { ok: true; value: rt.u8 }).value; rt.byteVecExtendFromSlice(out, rt.byteSliceFrom(Uint8Array.of(a2, (parsed as { ok: true; value: rt.u8 }).value, (parsed as { ok: true; value: rt.u8 }).value, early(a2)))); - const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtResult(parsed, f, rt.u8Display, (value: Void.Void, f: rt.Formatter) => Void.fmt$Debug(value, f))]; + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtResult(parsed, f, rt.u8Debug, (value: Void.Void, f: rt.Formatter) => Void.fmt$Debug(value, f))]; rt.byteVecExtendFromSlice(out, rt.stringAsBytes(rt.fmtFormat([args2[0]]))); payloads(data, out); known(data, out); diff --git a/ts/fixtures/lang/src/durations.rs b/ts/fixtures/lang/src/durations.rs index 7c36867ea..8e007ece0 100644 --- a/ts/fixtures/lang/src/durations.rs +++ b/ts/fixtures/lang/src/durations.rs @@ -135,6 +135,26 @@ pub fn durations(kind: u8, data: &[u8], out: &mut Vec) { out, &format!("{a:?}|{c:?}|{d:?}|{c:>16?}|{d:*^14?}|{c:<12?}|{a:08?}|{:?}", Some(b)), ); + // A precision rounds the fraction half to even, carrying into the whole part. + let p = (n % 13) as usize; + put( + out, + &format!( + "{a:.0?}|{a:.3?}|{c:.1?}|{d:.12?}|{a:+?}|{c:+12.2?}|{d:<10.1?}|{a:.p$?}|{:.1?}", + Some(b) + ), + ); + for d in [ + 1_500_000_000, + 2_500_000_000, + 1_250_000, + 1_350_000, + 999_500, + 1_999_999_999, + ] { + let d = Duration::from_nanos(d); + put(out, &format!("{d:.0?} {d:.1?} {d:.2?}")); + } } _ => { // Constants, `Default`, and a field. diff --git a/ts/fixtures/lang/src/fmt.rs b/ts/fixtures/lang/src/fmt.rs index a7b0d6283..7a90a5133 100644 --- a/ts/fixtures/lang/src/fmt.rs +++ b/ts/fixtures/lang/src/fmt.rs @@ -1,5 +1,5 @@ -//! Formatting: `format!` and `write!` with every option the subset has, derived and -//! written `Debug` and `Display`, and panics that format their messages. +//! Formatting: `format!` and `write!` with every option, derived and written `Debug` and +//! `Display`, and panics that format their messages. #![allow(dead_code, reason = "fields only `Debug` reads")] @@ -19,7 +19,8 @@ macro_rules! take { }}; } -/// Every option on one integer: width, fill, alignment, zeros, and hex. +/// Every option on one integer: width, fill, alignment, signs, zeros, precision, and +/// each radix and exponent. macro_rules! specs { ($t:ty, $data:expr, $out:expr) => {{ let v = take!($t, $data); @@ -29,6 +30,16 @@ macro_rules! specs { "{v} {v:?} {v:5}|{v:<5}|{v:^7}|{v:>4}|{v:*^9}|{v:é>6}|{v:05}|{v:<05}|{v:x} {v:X} {v:#x} {v:#X} {v:08x} {v:#010x} {v:>8x}|{v:<#6X}|{v:#?} {v:3?}" ), ); + put( + $out, + &format!( + "{v:+} {v:+06} {v:+#x} {v:-} {v:.3} {v:8.2}|{v:b} {v:#b} {v:#012b} {v:o} {v:#o} {v:+o}|{v:x?} {v:#X?} {v:06x?} {v:+?}" + ), + ); + put( + $out, + &format!("{v:e} {v:E} {v:.0e} {v:.1e} {v:.3e} {v:.45E} {v:+.2e} {v:012.1e} {v:<+9e}| {v:#e} {v:>12.4E}|"), + ); put($out, &v.to_string()); }}; } @@ -82,17 +93,32 @@ pub fn strings(data: &[u8], out: &mut Vec) { out, &format!("{s}|{s:8}|{s:>8}|{s:^8}|{s:-<3}|{s:?}|{s:12?}|{s:#?}|{{{s}}}"), ); + // A precision cuts by chars, then the width pads; `Debug` of a string takes neither. + put( + out, + &format!("{s:.2}|{s:8.3}|{s:>6.1}|{s:_^7.2}|{s:.0}|{s:.20}|{s:.2?}|{s:10.2?}|{s:+}"), + ); } + let c = char::from_u32(u32::from(data.first().copied().unwrap_or(0)) * 0x101).unwrap_or('?'); + put(out, &format!("{c}|{c:.0}|{c:3.1}|{c:.0?}|{c:>4?}")); match String::from_utf8(data.to_vec()) { - Ok(s) => put(out, &format!("{s:?} {s:>4}")), - Err(e) => put(out, &format!("{e} {e:?} {e:#?} {e:>80}")), + Ok(s) => put(out, &format!("{s:?} {s:>4} {s:.1}")), + Err(e) => put(out, &format!("{e} {e:?} {e:#?} {e:>80} {e:.4} {e:x?} {e:#X?}")), } let flag = matches!(data.first(), Some(b) if b % 2 == 0); - put(out, &format!("{flag} {flag:?} {flag:>6} {:?} {:#?}", (), ())); + put( + out, + &format!( + "{flag} {flag:?} {flag:>6} {flag:.2} {flag:>4.1?} {:?} {:#?} {:.1?}", + (), + (), + () + ), + ); put(out, &flag.to_string()); match u8::try_from(data.len() as i32 - 3) { Ok(v) => put(out, &format!("{v}")), - Err(e) => put(out, &format!("{e} {e:?} {e:>40}|")), + Err(e) => put(out, &format!("{e} {e:?} {e:>40}| {e:.6}|{e:10.3}|")), } } @@ -197,6 +223,10 @@ pub fn derived(data: &[u8], out: &mut Vec) { let value = nested(data); put(out, &format!("{value:?}")); put(out, &format!("{value:#?}")); + // Each field takes the options: hex for integers, and the precision for strings. + put(out, &format!("{value:x?}")); + put(out, &format!("{value:#X?}")); + put(out, &format!("{value:+.1?}")); let wide = Wide { a: at(0), b: 300, @@ -241,6 +271,31 @@ pub fn derived(data: &[u8], out: &mut Vec) { /// `Display` written with `write!`, which ignores the outer options, unless `#`. pub struct Hex(pub u32); +/// Through to the field, which takes the options. +impl fmt::Binary for Hex { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + fmt::Binary::fmt(&self.0, f) + } +} + +impl fmt::Octal for Hex { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{:o}", self.0) + } +} + +impl fmt::LowerExp for Hex { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + fmt::LowerExp::fmt(&self.0, f) + } +} + +impl fmt::UpperExp for Hex { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + fmt::UpperExp::fmt(&self.0, f) + } +} + impl fmt::Display for Hex { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match f.alternate() { @@ -353,6 +408,11 @@ pub fn written(data: &[u8], out: &mut Vec) { let at = |i: usize| data.get(i).copied().unwrap_or(0); let hex = Hex(u32::from(at(0)) * 0x1001); put(out, &format!("{hex}|{hex:>12}|{hex:#}|{hex:?}|{hex:>6?}|{hex:#?}")); + // `Debug` through `Display` is decimal under `{:x?}` too. + put( + out, + &format!("{hex:x?}|{hex:#b}|{hex:>8o}|{hex:.2e}|{hex:E}|{hex:+.1?}"), + ); put(out, &hex.to_string()); let padded = Padded("pad"); put(out, &format!("{padded}|{padded:>6}|{padded:_^9}|{padded:30}|")); @@ -399,6 +459,39 @@ pub fn written(data: &[u8], out: &mut Vec) { } } +/// Widths and precisions from arguments, by position and by name, and one past +/// `u16::MAX`, which panics. +pub fn counts(data: &[u8], out: &mut Vec) { + let at = |i: usize| data.get(i).copied().unwrap_or(0); + let (w, p) = (usize::from(at(0) % 24), usize::from(at(1) % 12)); + let v = take!(i64, &data[data.len().min(2)..]); + let s = STRINGS[usize::from(at(3)) % STRINGS.len()]; + put( + out, + &format!( + "{v:w$}|{v:0$}|{1:2$.0$}|{s:>p$?}", + p, s, w + ), + ); + // Each argument is evaluated once, before any is written, even a count. + let mut log = Vec::new(); + put( + out, + &format!("{:>1$}|{:.*}", note(&mut log, at(4)), usize::from(note(&mut log, 6)), s), + ); + out.extend_from_slice(&log); + let big = usize::from(u16::MAX) + usize::from(at(5) % 2); + put(out, &format!("{s:.big$}|")); +} + +/// `{:e}` at each rounding: below, above, and ties to even, which may carry a digit. +pub fn rounding(out: &mut Vec) { + for v in [0u32, 5, 15, 25, 125, 135, 994, 995, 999, 1000, 1_250_000, 4_294_967_295] { + put(out, &format!("{v:.0e} {v:.1e} {v:.2e} {v:e}")); + } + put(out, &format!("{:.0e} {:e} {:.3E}", u128::MAX, i128::MIN, i64::MIN)); +} + /// Panics, each with the message native Rust formats. pub fn panics(kind: u8, rest: &[u8], out: &mut Vec) { let n = rest.first().copied().unwrap_or(0); diff --git a/ts/fixtures/lang/src/harness.rs b/ts/fixtures/lang/src/harness.rs index 03d1729b4..614171e3d 100644 --- a/ts/fixtures/lang/src/harness.rs +++ b/ts/fixtures/lang/src/harness.rs @@ -22,7 +22,7 @@ pub fn run(input: &[u8]) -> Vec { return out; }; let (op, kind) = (*op, *kind); - match op % 52 { + match op % 54 { 0 => ints::u8_op(kind, data, &mut out), 1 => ints::u16_op(kind, data, &mut out), 2 => ints::u32_op(kind, data, &mut out), @@ -84,6 +84,8 @@ pub fn run(input: &[u8]) -> Vec { 48 => combinators::combinators(kind, data, &mut out), 49 => splits::splits(kind, data, &mut out), 50 => refs::refs(data, &mut out), + 51 => fmt::counts(data, &mut out), + 52 => fmt::rounding(&mut out), _ => iters::skips(kind, data, &mut out), } out diff --git a/ts/fixtures/reject/census.md b/ts/fixtures/reject/census.md index 846a14f13..8b235abef 100644 --- a/ts/fixtures/reject/census.md +++ b/ts/fixtures/reject/census.md @@ -1,6 +1,6 @@ # Census of `reject-fixture` -- Refusals: 86 +- Refusals: 78 - Function instances: 73 - Generic functions no instance reached, lowered over their type parameters: 2 @@ -11,50 +11,42 @@ | 10 | unsupported call to `_` | fixtures/reject/src/lib.rs:28:4 | | 6 | `_` is not supported: its `None` and `Some` would both be `undefined` | fixtures/reject/src/lib.rs:23:15 | | 5 | passing `_`, a closure that owns a value that drops, to `_`, which is not supported yet | fixtures/reject/src/lib.rs:45:11 | -| 4 | a variant of `_`, which is not supported: either is the same JS string | fixtures/reject/src/lib.rs:397:2 | -| 4 | an assignment through a reference to `_` | fixtures/reject/src/lib.rs:109:2 | +| 4 | a variant of `_`, which is not supported: either is the same JS string | fixtures/reject/src/lib.rs:387:2 | +| 4 | an assignment through a reference to `_` | fixtures/reject/src/lib.rs:99:2 | | 4 | unsupported type `_` | fixtures/reject/src/lib.rs:7:14 | | 3 | `_` with a mutable reference to a value JS copies, which its mapping would copy | fixtures/reject/src/lib.rs:17:2 | | 3 | dropping `_`, which is not supported yet | fixtures/reject/src/lib.rs:45:18 | -| 3 | replacing the value behind a reference to `_` | fixtures/reject/src/lib.rs:93:2 | -| 2 | `_` is not supported: it would be pending two ways with one value | fixtures/reject/src/lib.rs:113:20 | -| 2 | `_` of a reference to an array of bytes it is generic over, which its mapping would take as the array, not as a slice of it | fixtures/reject/src/lib.rs:265:16 | -| 2 | a field of `_` | fixtures/reject/src/lib.rs:281:7 | -| 2 | an iterator of the crate implementing `_`, which is not supported yet | fixtures/reject/src/lib.rs:172:1 | -| 2 | constructing `_` from another crate | fixtures/reject/src/lib.rs:158:23 | -| 2 | overriding `_`, which std's adaptors call in place of `next` or beside it | fixtures/reject/src/lib.rs:152:2 | -| 1 | `Binary` formatting, as in `{:b}`, is not supported | fixtures/reject/src/lib.rs:70:3 | -| 1 | `LowerExp` formatting, as in `{:e}`, is not supported | fixtures/reject/src/lib.rs:72:3 | -| 1 | `Octal` formatting, as in `{:o}`, is not supported | fixtures/reject/src/lib.rs:71:3 | -| 1 | `Pointer` formatting, as in `{:p}`, is not supported | fixtures/reject/src/lib.rs:75:3 | -| 1 | `_` holds `_`, which is `undefined` as `None` is, which is not supported | fixtures/reject/src/lib.rs:286:6 | -| 1 | `_` is not supported yet | fixtures/reject/src/lib.rs:408:18 | -| 1 | `_` of `_` by `_`, which is not supported yet | fixtures/reject/src/lib.rs:309:6 | +| 3 | replacing the value behind a reference to `_` | fixtures/reject/src/lib.rs:83:2 | +| 2 | `_` is not supported: it would be pending two ways with one value | fixtures/reject/src/lib.rs:103:20 | +| 2 | `_` of a reference to an array of bytes it is generic over, which its mapping would take as the array, not as a slice of it | fixtures/reject/src/lib.rs:255:16 | +| 2 | a field of `_` | fixtures/reject/src/lib.rs:271:7 | +| 2 | an iterator of the crate implementing `_`, which is not supported yet | fixtures/reject/src/lib.rs:162:1 | +| 2 | constructing `_` from another crate | fixtures/reject/src/lib.rs:148:23 | +| 2 | overriding `_`, which std's adaptors call in place of `next` or beside it | fixtures/reject/src/lib.rs:142:2 | +| 1 | `Pointer` formatting, as in `{:p}`, is not supported | fixtures/reject/src/lib.rs:66:2 | +| 1 | `_` holds `_`, which is `undefined` as `None` is, which is not supported | fixtures/reject/src/lib.rs:276:6 | +| 1 | `_` is not supported yet | fixtures/reject/src/lib.rs:398:18 | +| 1 | `_` of `_` by `_`, which is not supported yet | fixtures/reject/src/lib.rs:299:6 | | 1 | `_` of `_`, which drops `_`, which is not supported yet | fixtures/reject/src/lib.rs:51:13 | -| 1 | `_` through a held type's own, which is not supported yet | fixtures/reject/src/lib.rs:341:2 | -| 1 | `_`, which is not supported yet | fixtures/reject/src/lib.rs:317:9 | -| 1 | `fold` of `_`, which folds a `flatten` whose source and iterators both drop, which is not supported yet | fixtures/reject/src/lib.rs:234:26 | -| 1 | a `_` cast from `_` to `_` | fixtures/reject/src/lib.rs:104:2 | -| 1 | a `zip` of `_` and `_`, which std reads by index, of items that drop, which is not supported yet | fixtures/reject/src/lib.rs:239:30 | -| 1 | a `zip` of `_`, whose closures std calls one item further through `next` than through `fold` | fixtures/reject/src/lib.rs:185:51 | -| 1 | a coercion to `_` | fixtures/reject/src/lib.rs:364:2 | -| 1 | a constant of type `_` | fixtures/reject/src/lib.rs:88:2 | -| 1 | a copy of a closure that changes what it captured | fixtures/reject/src/lib.rs:275:14 | -| 1 | a mutable borrow of a subslice of `_`, which JS would copy, having no views | fixtures/reject/src/lib.rs:244:13 | -| 1 | a mutable reference into a `Result`'s payload, passed on or kept | fixtures/reject/src/lib.rs:446:12 | -| 1 | a precision, as in `{:.2}`, is not supported | fixtures/reject/src/lib.rs:67:3 | -| 1 | a printable type must implement `Display` or `Debug` | fixtures/reject/src/lib.rs:100:1 | +| 1 | `_` through a held type's own, which is not supported yet | fixtures/reject/src/lib.rs:331:2 | +| 1 | `_`, which is not supported yet | fixtures/reject/src/lib.rs:307:9 | +| 1 | `fold` of `_`, which folds a `flatten` whose source and iterators both drop, which is not supported yet | fixtures/reject/src/lib.rs:224:26 | +| 1 | a `_` cast from `_` to `_` | fixtures/reject/src/lib.rs:94:2 | +| 1 | a `zip` of `_` and `_`, which std reads by index, of items that drop, which is not supported yet | fixtures/reject/src/lib.rs:229:30 | +| 1 | a `zip` of `_`, whose closures std calls one item further through `next` than through `fold` | fixtures/reject/src/lib.rs:175:51 | +| 1 | a coercion to `_` | fixtures/reject/src/lib.rs:354:2 | +| 1 | a constant of type `_` | fixtures/reject/src/lib.rs:78:2 | +| 1 | a copy of a closure that changes what it captured | fixtures/reject/src/lib.rs:265:14 | +| 1 | a mutable borrow of a subslice of `_`, which JS would copy, having no views | fixtures/reject/src/lib.rs:234:13 | +| 1 | a mutable reference into a `Result`'s payload, passed on or kept | fixtures/reject/src/lib.rs:436:12 | +| 1 | a printable type must implement `Display` or `Debug` | fixtures/reject/src/lib.rs:90:1 | | 1 | a scalar constant of type `_` | fixtures/reject/src/lib.rs:8:2 | -| 1 | a width or precision from an argument, as in `{:1$}`, is not supported | fixtures/reject/src/lib.rs:74:3 | | 1 | a zero-sized constant of type `_` | fixtures/reject/src/lib.rs:60:2 | -| 1 | an iterator that owns `_`, which drops, which is not supported yet | fixtures/reject/src/lib.rs:391:13 | +| 1 | an iterator that owns `_`, which drops, which is not supported yet | fixtures/reject/src/lib.rs:381:13 | | 1 | arithmetic on `_` | fixtures/reject/src/lib.rs:8:2 | -| 1 | comparing `_` as a key, which is not supported yet | fixtures/reject/src/lib.rs:291:52 | -| 1 | constructing `_` | fixtures/reject/src/lib.rs:415:53 | -| 1 | hashing `_` as a key, which is not supported yet | fixtures/reject/src/lib.rs:291:52 | -| 1 | hex `Debug`, as in `{:x?}`, is not supported | fixtures/reject/src/lib.rs:73:3 | -| 1 | the `+` flag of a format spec is not supported | fixtures/reject/src/lib.rs:68:3 | -| 1 | the `-` flag of a format spec is not supported | fixtures/reject/src/lib.rs:69:3 | +| 1 | comparing `_` as a key, which is not supported yet | fixtures/reject/src/lib.rs:281:52 | +| 1 | constructing `_` | fixtures/reject/src/lib.rs:405:53 | +| 1 | hashing `_` as a key, which is not supported yet | fixtures/reject/src/lib.rs:281:52 | ## By API @@ -62,7 +54,7 @@ The type or module each refused type or path belongs to. | Count | API | First | | ---: | --- | --- | -| 7 | `std::borrow::Cow` | fixtures/reject/src/lib.rs:397:2 | +| 7 | `std::borrow::Cow` | fixtures/reject/src/lib.rs:387:2 | | 6 | `Option` | fixtures/reject/src/lib.rs:23:15 | | 6 | `f64` | fixtures/reject/src/lib.rs:7:14 | | 5 | `{closure}` | fixtures/reject/src/lib.rs:45:11 | @@ -70,43 +62,43 @@ The type or module each refused type or path belongs to. | 3 | `std::collections::HashMap` | fixtures/reject/src/lib.rs:51:13 | | 3 | `std::iter::Map` | fixtures/reject/src/lib.rs:45:18 | | 3 | `std::slice` | fixtures/reject/src/lib.rs:28:4 | -| 3 | `std::sync::Arc` | fixtures/reject/src/lib.rs:109:2 | -| 2 | `Meters` | fixtures/reject/src/lib.rs:93:2 | +| 3 | `std::sync::Arc` | fixtures/reject/src/lib.rs:99:2 | +| 2 | `Meters` | fixtures/reject/src/lib.rs:83:2 | | 2 | `Noisy` | fixtures/reject/src/lib.rs:51:13 | -| 2 | `Poll` | fixtures/reject/src/lib.rs:113:20 | -| 2 | `std::iter::Iterator` | fixtures/reject/src/lib.rs:265:16 | -| 2 | `std::iter::Take` | fixtures/reject/src/lib.rs:389:79 | -| 2 | `std::ops::Range` | fixtures/reject/src/lib.rs:193:8 | -| 2 | `std::option::Option` | fixtures/reject/src/lib.rs:286:6 | -| 2 | `std::pin::Pin` | fixtures/reject/src/lib.rs:129:2 | -| 2 | `std::vec::Vec` | fixtures/reject/src/lib.rs:291:52 | -| 2 | `u8` | fixtures/reject/src/lib.rs:88:2 | -| 1 | `DoubleEndedIterator` | fixtures/reject/src/lib.rs:172:1 | -| 1 | `Entry` | fixtures/reject/src/lib.rs:380:13 | -| 1 | `FusedIterator` | fixtures/reject/src/lib.rs:226:1 | -| 1 | `HashMap` | fixtures/reject/src/lib.rs:309:6 | -| 1 | `Hasher` | fixtures/reject/src/lib.rs:317:9 | -| 1 | `IntToFloat` | fixtures/reject/src/lib.rs:104:2 | -| 1 | `[u16; 1]` | fixtures/reject/src/lib.rs:258:22 | +| 2 | `Poll` | fixtures/reject/src/lib.rs:103:20 | +| 2 | `std::iter::Iterator` | fixtures/reject/src/lib.rs:255:16 | +| 2 | `std::iter::Take` | fixtures/reject/src/lib.rs:379:79 | +| 2 | `std::ops::Range` | fixtures/reject/src/lib.rs:183:8 | +| 2 | `std::option::Option` | fixtures/reject/src/lib.rs:276:6 | +| 2 | `std::pin::Pin` | fixtures/reject/src/lib.rs:119:2 | +| 2 | `std::vec::Vec` | fixtures/reject/src/lib.rs:281:52 | +| 2 | `u8` | fixtures/reject/src/lib.rs:78:2 | +| 1 | `DoubleEndedIterator` | fixtures/reject/src/lib.rs:162:1 | +| 1 | `Entry` | fixtures/reject/src/lib.rs:370:13 | +| 1 | `FusedIterator` | fixtures/reject/src/lib.rs:216:1 | +| 1 | `HashMap` | fixtures/reject/src/lib.rs:299:6 | +| 1 | `Hasher` | fixtures/reject/src/lib.rs:307:9 | +| 1 | `IntToFloat` | fixtures/reject/src/lib.rs:94:2 | +| 1 | `[u16; 1]` | fixtures/reject/src/lib.rs:248:22 | | 1 | `dyn std::ops::Fn(u8) -> u8` | fixtures/reject/src/lib.rs:11:16 | -| 1 | `from_fn` | fixtures/reject/src/lib.rs:390:13 | +| 1 | `from_fn` | fixtures/reject/src/lib.rs:380:13 | | 1 | `into_keys` | fixtures/reject/src/lib.rs:51:13 | -| 1 | `std::collections::hash_map::Entry` | fixtures/reject/src/lib.rs:436:15 | -| 1 | `std::iter::Chain` | fixtures/reject/src/lib.rs:185:51 | -| 1 | `std::iter::Flatten` | fixtures/reject/src/lib.rs:234:26 | +| 1 | `std::collections::hash_map::Entry` | fixtures/reject/src/lib.rs:426:15 | +| 1 | `std::iter::Chain` | fixtures/reject/src/lib.rs:175:51 | +| 1 | `std::iter::Flatten` | fixtures/reject/src/lib.rs:224:26 | | 1 | `std::iter::IntoIterator` | fixtures/reject/src/lib.rs:17:2 | -| 1 | `std::iter::Rev` | fixtures/reject/src/lib.rs:179:14 | +| 1 | `std::iter::Rev` | fixtures/reject/src/lib.rs:169:14 | | 1 | `std::mem` | fixtures/reject/src/lib.rs:44:29 | -| 1 | `std::ops::RangeFrom` | fixtures/reject/src/lib.rs:281:48 | -| 1 | `std::ops::RangeTo` | fixtures/reject/src/lib.rs:281:7 | -| 1 | `std::slice::Iter` | fixtures/reject/src/lib.rs:139:11 | -| 1 | `std::str` | fixtures/reject/src/lib.rs:370:4 | -| 1 | `std::string::String` | fixtures/reject/src/lib.rs:82:10 | -| 1 | `std::sync::MutexGuard` | fixtures/reject/src/lib.rs:134:2 | -| 1 | `std::time::Duration` | fixtures/reject/src/lib.rs:423:2 | -| 1 | `successors` | fixtures/reject/src/lib.rs:389:15 | -| 1 | `u32` | fixtures/reject/src/lib.rs:244:13 | -| 1 | `u64` | fixtures/reject/src/lib.rs:104:2 | +| 1 | `std::ops::RangeFrom` | fixtures/reject/src/lib.rs:271:48 | +| 1 | `std::ops::RangeTo` | fixtures/reject/src/lib.rs:271:7 | +| 1 | `std::slice::Iter` | fixtures/reject/src/lib.rs:129:11 | +| 1 | `std::str` | fixtures/reject/src/lib.rs:360:4 | +| 1 | `std::string::String` | fixtures/reject/src/lib.rs:72:10 | +| 1 | `std::sync::MutexGuard` | fixtures/reject/src/lib.rs:124:2 | +| 1 | `std::time::Duration` | fixtures/reject/src/lib.rs:413:2 | +| 1 | `successors` | fixtures/reject/src/lib.rs:379:15 | +| 1 | `u32` | fixtures/reject/src/lib.rs:234:13 | +| 1 | `u64` | fixtures/reject/src/lib.rs:94:2 | | 1 | `{async closure}` | fixtures/reject/src/lib.rs:60:2 | ## By type or path @@ -114,64 +106,64 @@ The type or module each refused type or path belongs to. | Count | Construct | Type or path | First | | ---: | --- | --- | --- | | 6 | `_` is not supported: its `None` and `Some` would both be `undefined` | `Option` | fixtures/reject/src/lib.rs:23:15 | -| 4 | a variant of `_`, which is not supported: either is the same JS string | `std::borrow::Cow` | fixtures/reject/src/lib.rs:397:2 | +| 4 | a variant of `_`, which is not supported: either is the same JS string | `std::borrow::Cow` | fixtures/reject/src/lib.rs:387:2 | | 3 | unsupported type `_` | `f64` | fixtures/reject/src/lib.rs:7:14 | -| 2 | `_` is not supported: it would be pending two ways with one value | `Poll` | fixtures/reject/src/lib.rs:113:20 | -| 2 | an assignment through a reference to `_` | `std::pin::Pin` | fixtures/reject/src/lib.rs:129:2 | -| 2 | dropping `_`, which is not supported yet | `std::iter::Take` | fixtures/reject/src/lib.rs:389:79 | -| 2 | replacing the value behind a reference to `_` | `Meters` | fixtures/reject/src/lib.rs:93:2 | -| 1 | `_` holds `_`, which is `undefined` as `None` is, which is not supported | `std::collections::HashMap`, `std::option::Option` | fixtures/reject/src/lib.rs:286:6 | -| 1 | `_` is not supported yet | `std::borrow::Cow` | fixtures/reject/src/lib.rs:408:18 | -| 1 | `_` of `_` by `_`, which is not supported yet | `HashMap::contains_key`, `std::collections::HashMap`, `u8` | fixtures/reject/src/lib.rs:309:6 | +| 2 | `_` is not supported: it would be pending two ways with one value | `Poll` | fixtures/reject/src/lib.rs:103:20 | +| 2 | an assignment through a reference to `_` | `std::pin::Pin` | fixtures/reject/src/lib.rs:119:2 | +| 2 | dropping `_`, which is not supported yet | `std::iter::Take` | fixtures/reject/src/lib.rs:379:79 | +| 2 | replacing the value behind a reference to `_` | `Meters` | fixtures/reject/src/lib.rs:83:2 | +| 1 | `_` holds `_`, which is `undefined` as `None` is, which is not supported | `std::collections::HashMap`, `std::option::Option` | fixtures/reject/src/lib.rs:276:6 | +| 1 | `_` is not supported yet | `std::borrow::Cow` | fixtures/reject/src/lib.rs:398:18 | +| 1 | `_` of `_` by `_`, which is not supported yet | `HashMap::contains_key`, `std::collections::HashMap`, `u8` | fixtures/reject/src/lib.rs:299:6 | | 1 | `_` of `_`, which drops `_`, which is not supported yet | `into_keys`, `std::collections::HashMap`, `Noisy` | fixtures/reject/src/lib.rs:51:13 | -| 1 | `_` of a reference to an array of bytes it is generic over, which its mapping would take as the array, not as a slice of it | `std::iter::Iterator::count` | fixtures/reject/src/lib.rs:265:38 | -| 1 | `_` of a reference to an array of bytes it is generic over, which its mapping would take as the array, not as a slice of it | `std::iter::Iterator::filter` | fixtures/reject/src/lib.rs:265:16 | -| 1 | `_` through a held type's own, which is not supported yet | `::ne` | fixtures/reject/src/lib.rs:341:2 | -| 1 | `_` with a mutable reference to a value JS copies, which its mapping would copy | `std::collections::hash_map::Entry::and_modify` | fixtures/reject/src/lib.rs:436:15 | +| 1 | `_` of a reference to an array of bytes it is generic over, which its mapping would take as the array, not as a slice of it | `std::iter::Iterator::count` | fixtures/reject/src/lib.rs:255:38 | +| 1 | `_` of a reference to an array of bytes it is generic over, which its mapping would take as the array, not as a slice of it | `std::iter::Iterator::filter` | fixtures/reject/src/lib.rs:255:16 | +| 1 | `_` through a held type's own, which is not supported yet | `::ne` | fixtures/reject/src/lib.rs:331:2 | +| 1 | `_` with a mutable reference to a value JS copies, which its mapping would copy | `std::collections::hash_map::Entry::and_modify` | fixtures/reject/src/lib.rs:426:15 | | 1 | `_` with a mutable reference to a value JS copies, which its mapping would copy | `std::iter::IntoIterator::into_iter` | fixtures/reject/src/lib.rs:17:2 | -| 1 | `_` with a mutable reference to a value JS copies, which its mapping would copy | `std::slice::last_mut` | fixtures/reject/src/lib.rs:429:21 | -| 1 | `_`, which is not supported yet | `Hasher::write` | fixtures/reject/src/lib.rs:317:9 | -| 1 | `fold` of `_`, which folds a `flatten` whose source and iterators both drop, which is not supported yet | `std::iter::Flatten` | fixtures/reject/src/lib.rs:234:26 | -| 1 | a `_` cast from `_` to `_` | `IntToFloat`, `u64`, `f64` | fixtures/reject/src/lib.rs:104:2 | -| 1 | a `zip` of `_` and `_`, which std reads by index, of items that drop, which is not supported yet | `std::iter::Map`, `std::ops::Range` | fixtures/reject/src/lib.rs:239:30 | -| 1 | a `zip` of `_`, whose closures std calls one item further through `next` than through `fold` | `std::iter::Chain` | fixtures/reject/src/lib.rs:185:51 | -| 1 | a coercion to `_` | `std::sync::Arc` | fixtures/reject/src/lib.rs:364:2 | -| 1 | a constant of type `_` | `&u8` | fixtures/reject/src/lib.rs:88:2 | -| 1 | a field of `_` | `std::ops::RangeFrom` | fixtures/reject/src/lib.rs:281:48 | -| 1 | a field of `_` | `std::ops::RangeTo` | fixtures/reject/src/lib.rs:281:7 | -| 1 | a mutable borrow of a subslice of `_`, which JS would copy, having no views | `u32` | fixtures/reject/src/lib.rs:244:13 | +| 1 | `_` with a mutable reference to a value JS copies, which its mapping would copy | `std::slice::last_mut` | fixtures/reject/src/lib.rs:419:21 | +| 1 | `_`, which is not supported yet | `Hasher::write` | fixtures/reject/src/lib.rs:307:9 | +| 1 | `fold` of `_`, which folds a `flatten` whose source and iterators both drop, which is not supported yet | `std::iter::Flatten` | fixtures/reject/src/lib.rs:224:26 | +| 1 | a `_` cast from `_` to `_` | `IntToFloat`, `u64`, `f64` | fixtures/reject/src/lib.rs:94:2 | +| 1 | a `zip` of `_` and `_`, which std reads by index, of items that drop, which is not supported yet | `std::iter::Map`, `std::ops::Range` | fixtures/reject/src/lib.rs:229:30 | +| 1 | a `zip` of `_`, whose closures std calls one item further through `next` than through `fold` | `std::iter::Chain` | fixtures/reject/src/lib.rs:175:51 | +| 1 | a coercion to `_` | `std::sync::Arc` | fixtures/reject/src/lib.rs:354:2 | +| 1 | a constant of type `_` | `&u8` | fixtures/reject/src/lib.rs:78:2 | +| 1 | a field of `_` | `std::ops::RangeFrom` | fixtures/reject/src/lib.rs:271:48 | +| 1 | a field of `_` | `std::ops::RangeTo` | fixtures/reject/src/lib.rs:271:7 | +| 1 | a mutable borrow of a subslice of `_`, which JS would copy, having no views | `u32` | fixtures/reject/src/lib.rs:234:13 | | 1 | a scalar constant of type `_` | `f64` | fixtures/reject/src/lib.rs:8:2 | | 1 | a zero-sized constant of type `_` | `{async closure}` | fixtures/reject/src/lib.rs:60:2 | -| 1 | an assignment through a reference to `_` | `std::sync::Arc` | fixtures/reject/src/lib.rs:109:2 | -| 1 | an assignment through a reference to `_` | `std::sync::MutexGuard` | fixtures/reject/src/lib.rs:134:2 | -| 1 | an iterator of the crate implementing `_`, which is not supported yet | `DoubleEndedIterator` | fixtures/reject/src/lib.rs:172:1 | -| 1 | an iterator of the crate implementing `_`, which is not supported yet | `FusedIterator` | fixtures/reject/src/lib.rs:226:1 | -| 1 | an iterator that owns `_`, which drops, which is not supported yet | `Noisy` | fixtures/reject/src/lib.rs:391:13 | +| 1 | an assignment through a reference to `_` | `std::sync::Arc` | fixtures/reject/src/lib.rs:99:2 | +| 1 | an assignment through a reference to `_` | `std::sync::MutexGuard` | fixtures/reject/src/lib.rs:124:2 | +| 1 | an iterator of the crate implementing `_`, which is not supported yet | `DoubleEndedIterator` | fixtures/reject/src/lib.rs:162:1 | +| 1 | an iterator of the crate implementing `_`, which is not supported yet | `FusedIterator` | fixtures/reject/src/lib.rs:216:1 | +| 1 | an iterator that owns `_`, which drops, which is not supported yet | `Noisy` | fixtures/reject/src/lib.rs:381:13 | | 1 | arithmetic on `_` | `f64` | fixtures/reject/src/lib.rs:8:2 | -| 1 | comparing `_` as a key, which is not supported yet | `std::vec::Vec` | fixtures/reject/src/lib.rs:291:52 | -| 1 | constructing `_` | `std::borrow::Cow` | fixtures/reject/src/lib.rs:415:53 | -| 1 | constructing `_` from another crate | `std::iter::Map` | fixtures/reject/src/lib.rs:158:23 | -| 1 | constructing `_` from another crate | `std::iter::Rev` | fixtures/reject/src/lib.rs:179:14 | +| 1 | comparing `_` as a key, which is not supported yet | `std::vec::Vec` | fixtures/reject/src/lib.rs:281:52 | +| 1 | constructing `_` | `std::borrow::Cow` | fixtures/reject/src/lib.rs:405:53 | +| 1 | constructing `_` from another crate | `std::iter::Map` | fixtures/reject/src/lib.rs:148:23 | +| 1 | constructing `_` from another crate | `std::iter::Rev` | fixtures/reject/src/lib.rs:169:14 | | 1 | dropping `_`, which is not supported yet | `std::iter::Map` | fixtures/reject/src/lib.rs:45:18 | -| 1 | hashing `_` as a key, which is not supported yet | `std::vec::Vec` | fixtures/reject/src/lib.rs:291:52 | -| 1 | overriding `_`, which std's adaptors call in place of `next` or beside it | `Iterator::fold` | fixtures/reject/src/lib.rs:152:2 | -| 1 | overriding `_`, which std's adaptors call in place of `next` or beside it | `Iterator::size_hint` | fixtures/reject/src/lib.rs:206:2 | -| 1 | passing `_`, a closure that owns a value that drops, to `_`, which is not supported yet | `{closure}`, `Entry::or_insert_with` | fixtures/reject/src/lib.rs:380:13 | -| 1 | passing `_`, a closure that owns a value that drops, to `_`, which is not supported yet | `{closure}`, `Iterator::any` | fixtures/reject/src/lib.rs:381:11 | +| 1 | hashing `_` as a key, which is not supported yet | `std::vec::Vec` | fixtures/reject/src/lib.rs:281:52 | +| 1 | overriding `_`, which std's adaptors call in place of `next` or beside it | `Iterator::fold` | fixtures/reject/src/lib.rs:142:2 | +| 1 | overriding `_`, which std's adaptors call in place of `next` or beside it | `Iterator::size_hint` | fixtures/reject/src/lib.rs:196:2 | +| 1 | passing `_`, a closure that owns a value that drops, to `_`, which is not supported yet | `{closure}`, `Entry::or_insert_with` | fixtures/reject/src/lib.rs:370:13 | +| 1 | passing `_`, a closure that owns a value that drops, to `_`, which is not supported yet | `{closure}`, `Iterator::any` | fixtures/reject/src/lib.rs:371:11 | | 1 | passing `_`, a closure that owns a value that drops, to `_`, which is not supported yet | `{closure}`, `Iterator::map` | fixtures/reject/src/lib.rs:45:11 | -| 1 | passing `_`, a closure that owns a value that drops, to `_`, which is not supported yet | `{closure}`, `from_fn::from_fn` | fixtures/reject/src/lib.rs:390:13 | -| 1 | passing `_`, a closure that owns a value that drops, to `_`, which is not supported yet | `{closure}`, `successors::successors` | fixtures/reject/src/lib.rs:389:15 | -| 1 | replacing the value behind a reference to `_` | `[u16; 1]` | fixtures/reject/src/lib.rs:258:22 | -| 1 | unsupported call to `_` | `::deref` | fixtures/reject/src/lib.rs:409:2 | -| 1 | unsupported call to `_` | `::eq` | fixtures/reject/src/lib.rs:453:2 | -| 1 | unsupported call to `_` | `::cycle` | fixtures/reject/src/lib.rs:139:11 | -| 1 | unsupported call to `_` | `::write_fmt` | fixtures/reject/src/lib.rs:82:10 | -| 1 | unsupported call to `_` | `::add_assign` | fixtures/reject/src/lib.rs:423:2 | +| 1 | passing `_`, a closure that owns a value that drops, to `_`, which is not supported yet | `{closure}`, `from_fn::from_fn` | fixtures/reject/src/lib.rs:380:13 | +| 1 | passing `_`, a closure that owns a value that drops, to `_`, which is not supported yet | `{closure}`, `successors::successors` | fixtures/reject/src/lib.rs:379:15 | +| 1 | replacing the value behind a reference to `_` | `[u16; 1]` | fixtures/reject/src/lib.rs:248:22 | +| 1 | unsupported call to `_` | `::deref` | fixtures/reject/src/lib.rs:399:2 | +| 1 | unsupported call to `_` | `::eq` | fixtures/reject/src/lib.rs:443:2 | +| 1 | unsupported call to `_` | `::cycle` | fixtures/reject/src/lib.rs:129:11 | +| 1 | unsupported call to `_` | `::write_fmt` | fixtures/reject/src/lib.rs:72:10 | +| 1 | unsupported call to `_` | `::add_assign` | fixtures/reject/src/lib.rs:413:2 | | 1 | unsupported call to `_` | `std::mem::size_of_val` | fixtures/reject/src/lib.rs:44:29 | -| 1 | unsupported call to `_` | `std::ops::Range::contains` | fixtures/reject/src/lib.rs:193:8 | -| 1 | unsupported call to `_` | `std::slice::copy_within` | fixtures/reject/src/lib.rs:359:4 | +| 1 | unsupported call to `_` | `std::ops::Range::contains` | fixtures/reject/src/lib.rs:183:8 | +| 1 | unsupported call to `_` | `std::slice::copy_within` | fixtures/reject/src/lib.rs:349:4 | | 1 | unsupported call to `_` | `std::slice::sort` | fixtures/reject/src/lib.rs:28:4 | -| 1 | unsupported call to `_` | `std::str::split` | fixtures/reject/src/lib.rs:370:4 | +| 1 | unsupported call to `_` | `std::str::split` | fixtures/reject/src/lib.rs:360:4 | | 1 | unsupported type `_` | `dyn std::ops::Fn(u8) -> u8` | fixtures/reject/src/lib.rs:11:16 | ## Spans @@ -180,14 +172,14 @@ The type or module each refused type or path belongs to. - fixtures/reject/src/lib.rs:28:4: unsupported call to `std::slice::::sort` - fixtures/reject/src/lib.rs:44:29: unsupported call to `std::mem::size_of_val::` -- fixtures/reject/src/lib.rs:82:10: unsupported call to `::write_fmt` -- fixtures/reject/src/lib.rs:139:11: unsupported call to ` as std::iter::Iterator>::cycle` -- fixtures/reject/src/lib.rs:193:8: unsupported call to `std::ops::Range::::contains::` -- fixtures/reject/src/lib.rs:359:4: unsupported call to `core::slice::::copy_within::>` -- fixtures/reject/src/lib.rs:370:4: unsupported call to `core::str::::split::<[char; 2]>` -- fixtures/reject/src/lib.rs:409:2: unsupported call to ` as std::ops::Deref>::deref` -- fixtures/reject/src/lib.rs:423:2: unsupported call to `::add_assign` -- fixtures/reject/src/lib.rs:453:2: unsupported call to ` as std::cmp::PartialEq>::eq` +- fixtures/reject/src/lib.rs:72:10: unsupported call to `::write_fmt` +- fixtures/reject/src/lib.rs:129:11: unsupported call to ` as std::iter::Iterator>::cycle` +- fixtures/reject/src/lib.rs:183:8: unsupported call to `std::ops::Range::::contains::` +- fixtures/reject/src/lib.rs:349:4: unsupported call to `core::slice::::copy_within::>` +- fixtures/reject/src/lib.rs:360:4: unsupported call to `core::str::::split::<[char; 2]>` +- fixtures/reject/src/lib.rs:399:2: unsupported call to ` as std::ops::Deref>::deref` +- fixtures/reject/src/lib.rs:413:2: unsupported call to `::add_assign` +- fixtures/reject/src/lib.rs:443:2: unsupported call to ` as std::cmp::PartialEq>::eq` @@ -197,36 +189,36 @@ The type or module each refused type or path belongs to. - fixtures/reject/src/lib.rs:24:2: `Option>` is not supported: its `None` and `Some` would both be `undefined` - fixtures/reject/src/lib.rs:32:2: `Option>` is not supported: its `None` and `Some` would both be `undefined` - fixtures/reject/src/lib.rs:32:42: `Option>` is not supported: its `None` and `Some` would both be `undefined` -- fixtures/reject/src/lib.rs:118:19: `Option>` is not supported: its `None` and `Some` would both be `undefined` -- fixtures/reject/src/lib.rs:286:2: `Option<&std::option::Option>` is not supported: its `None` and `Some` would both be `undefined` +- fixtures/reject/src/lib.rs:108:19: `Option>` is not supported: its `None` and `Some` would both be `undefined` +- fixtures/reject/src/lib.rs:276:2: `Option<&std::option::Option>` is not supported: its `None` and `Some` would both be `undefined`
passing `_`, a closure that owns a value that drops, to `_`, which is not supported yet (5) - fixtures/reject/src/lib.rs:45:11: passing `{closure@fixtures/reject/src/lib.rs:44:10: 44:23}`, a closure that owns a value that drops, to `Iterator::map`, which is not supported yet -- fixtures/reject/src/lib.rs:380:13: passing `{closure@fixtures/reject/src/lib.rs:380:28: 380:35}`, a closure that owns a value that drops, to `Entry::or_insert_with`, which is not supported yet -- fixtures/reject/src/lib.rs:381:11: passing `{closure@fixtures/reject/src/lib.rs:381:15: 381:24}`, a closure that owns a value that drops, to `Iterator::any`, which is not supported yet -- fixtures/reject/src/lib.rs:389:15: passing `{closure@fixtures/reject/src/lib.rs:389:48: 389:56}`, a closure that owns a value that drops, to `successors::successors`, which is not supported yet -- fixtures/reject/src/lib.rs:390:13: passing `{closure@fixtures/reject/src/lib.rs:390:32: 390:39}`, a closure that owns a value that drops, to `from_fn::from_fn`, which is not supported yet +- fixtures/reject/src/lib.rs:370:13: passing `{closure@fixtures/reject/src/lib.rs:370:28: 370:35}`, a closure that owns a value that drops, to `Entry::or_insert_with`, which is not supported yet +- fixtures/reject/src/lib.rs:371:11: passing `{closure@fixtures/reject/src/lib.rs:371:15: 371:24}`, a closure that owns a value that drops, to `Iterator::any`, which is not supported yet +- fixtures/reject/src/lib.rs:379:15: passing `{closure@fixtures/reject/src/lib.rs:379:48: 379:56}`, a closure that owns a value that drops, to `successors::successors`, which is not supported yet +- fixtures/reject/src/lib.rs:380:13: passing `{closure@fixtures/reject/src/lib.rs:380:32: 380:39}`, a closure that owns a value that drops, to `from_fn::from_fn`, which is not supported yet
a variant of `_`, which is not supported: either is the same JS string (4) -- fixtures/reject/src/lib.rs:397:2: a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string -- fixtures/reject/src/lib.rs:398:30: a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string -- fixtures/reject/src/lib.rs:399:27: a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string -- fixtures/reject/src/lib.rs:404:2: a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string +- fixtures/reject/src/lib.rs:387:2: a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string +- fixtures/reject/src/lib.rs:388:30: a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string +- fixtures/reject/src/lib.rs:389:27: a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string +- fixtures/reject/src/lib.rs:394:2: a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string
an assignment through a reference to `_` (4) -- fixtures/reject/src/lib.rs:109:2: an assignment through a reference to `std::sync::Arc` -- fixtures/reject/src/lib.rs:129:2: an assignment through a reference to `std::pin::Pin>` -- fixtures/reject/src/lib.rs:134:2: an assignment through a reference to `std::sync::MutexGuard<'_, u8>` -- fixtures/reject/src/lib.rs:252:2: an assignment through a reference to `std::pin::Pin<&mut Noisy>` +- fixtures/reject/src/lib.rs:99:2: an assignment through a reference to `std::sync::Arc` +- fixtures/reject/src/lib.rs:119:2: an assignment through a reference to `std::pin::Pin>` +- fixtures/reject/src/lib.rs:124:2: an assignment through a reference to `std::sync::MutexGuard<'_, u8>` +- fixtures/reject/src/lib.rs:242:2: an assignment through a reference to `std::pin::Pin<&mut Noisy>`
@@ -235,115 +227,97 @@ The type or module each refused type or path belongs to. - fixtures/reject/src/lib.rs:7:14: unsupported type `f64` - fixtures/reject/src/lib.rs:7:25: unsupported type `f64` - fixtures/reject/src/lib.rs:11:16: unsupported type `dyn std::ops::Fn(u8) -> u8` -- fixtures/reject/src/lib.rs:102:51: unsupported type `f64` +- fixtures/reject/src/lib.rs:92:51: unsupported type `f64`
`_` with a mutable reference to a value JS copies, which its mapping would copy (3) - fixtures/reject/src/lib.rs:17:2: `std::iter::IntoIterator::into_iter` with a mutable reference to a value JS copies, which its mapping would copy -- fixtures/reject/src/lib.rs:429:21: `core::slice::::last_mut` with a mutable reference to a value JS copies, which its mapping would copy -- fixtures/reject/src/lib.rs:436:15: `std::collections::hash_map::Entry::<'a, K, V, A>::and_modify` with a mutable reference to a value JS copies, which its mapping would copy +- fixtures/reject/src/lib.rs:419:21: `core::slice::::last_mut` with a mutable reference to a value JS copies, which its mapping would copy +- fixtures/reject/src/lib.rs:426:15: `std::collections::hash_map::Entry::<'a, K, V, A>::and_modify` with a mutable reference to a value JS copies, which its mapping would copy
dropping `_`, which is not supported yet (3) - fixtures/reject/src/lib.rs:45:18: dropping `std::iter::Map, {closure@fixtures/reject/src/lib.rs:44:10: 44:23}>`, which is not supported yet -- fixtures/reject/src/lib.rs:389:79: dropping `std::iter::Take>`, which is not supported yet -- fixtures/reject/src/lib.rs:390:62: dropping `std::iter::Take>`, which is not supported yet +- fixtures/reject/src/lib.rs:379:79: dropping `std::iter::Take>`, which is not supported yet +- fixtures/reject/src/lib.rs:380:62: dropping `std::iter::Take>`, which is not supported yet
replacing the value behind a reference to `_` (3) -- fixtures/reject/src/lib.rs:93:2: replacing the value behind a reference to `Meters` -- fixtures/reject/src/lib.rs:97:2: replacing the value behind a reference to `Meters` -- fixtures/reject/src/lib.rs:258:22: replacing the value behind a reference to `[u16; 1]` +- fixtures/reject/src/lib.rs:83:2: replacing the value behind a reference to `Meters` +- fixtures/reject/src/lib.rs:87:2: replacing the value behind a reference to `Meters` +- fixtures/reject/src/lib.rs:248:22: replacing the value behind a reference to `[u16; 1]`
`_` is not supported: it would be pending two ways with one value (2) -- fixtures/reject/src/lib.rs:113:20: `Poll>>` is not supported: it would be pending two ways with one value -- fixtures/reject/src/lib.rs:123:54: `Poll>` is not supported: it would be pending two ways with one value +- fixtures/reject/src/lib.rs:103:20: `Poll>>` is not supported: it would be pending two ways with one value +- fixtures/reject/src/lib.rs:113:54: `Poll>` is not supported: it would be pending two ways with one value
`_` of a reference to an array of bytes it is generic over, which its mapping would take as the array, not as a slice of it (2) -- fixtures/reject/src/lib.rs:265:16: `std::iter::Iterator::filter` of a reference to an array of bytes it is generic over, which its mapping would take as the array, not as a slice of it -- fixtures/reject/src/lib.rs:265:38: `std::iter::Iterator::count` of a reference to an array of bytes it is generic over, which its mapping would take as the array, not as a slice of it +- fixtures/reject/src/lib.rs:255:16: `std::iter::Iterator::filter` of a reference to an array of bytes it is generic over, which its mapping would take as the array, not as a slice of it +- fixtures/reject/src/lib.rs:255:38: `std::iter::Iterator::count` of a reference to an array of bytes it is generic over, which its mapping would take as the array, not as a slice of it
a field of `_` (2) -- fixtures/reject/src/lib.rs:281:7: a field of `std::ops::RangeTo` -- fixtures/reject/src/lib.rs:281:48: a field of `std::ops::RangeFrom` +- fixtures/reject/src/lib.rs:271:7: a field of `std::ops::RangeTo` +- fixtures/reject/src/lib.rs:271:48: a field of `std::ops::RangeFrom`
an iterator of the crate implementing `_`, which is not supported yet (2) -- fixtures/reject/src/lib.rs:172:1: an iterator of the crate implementing `DoubleEndedIterator`, which is not supported yet -- fixtures/reject/src/lib.rs:226:1: an iterator of the crate implementing `FusedIterator`, which is not supported yet +- fixtures/reject/src/lib.rs:162:1: an iterator of the crate implementing `DoubleEndedIterator`, which is not supported yet +- fixtures/reject/src/lib.rs:216:1: an iterator of the crate implementing `FusedIterator`, which is not supported yet
constructing `_` from another crate (2) -- fixtures/reject/src/lib.rs:158:23: constructing `std::iter::Map` from another crate -- fixtures/reject/src/lib.rs:179:14: constructing `std::iter::Rev` from another crate +- fixtures/reject/src/lib.rs:148:23: constructing `std::iter::Map` from another crate +- fixtures/reject/src/lib.rs:169:14: constructing `std::iter::Rev` from another crate
overriding `_`, which std's adaptors call in place of `next` or beside it (2) -- fixtures/reject/src/lib.rs:152:2: overriding `Iterator::fold`, which std's adaptors call in place of `next` or beside it -- fixtures/reject/src/lib.rs:206:2: overriding `Iterator::size_hint`, which std's adaptors call in place of `next` or beside it - -
- -
`Binary` formatting, as in `{:b}`, is not supported (1) - -- fixtures/reject/src/lib.rs:70:3: `Binary` formatting, as in `{:b}`, is not supported - -
- -
`LowerExp` formatting, as in `{:e}`, is not supported (1) - -- fixtures/reject/src/lib.rs:72:3: `LowerExp` formatting, as in `{:e}`, is not supported - -
- -
`Octal` formatting, as in `{:o}`, is not supported (1) - -- fixtures/reject/src/lib.rs:71:3: `Octal` formatting, as in `{:o}`, is not supported +- fixtures/reject/src/lib.rs:142:2: overriding `Iterator::fold`, which std's adaptors call in place of `next` or beside it +- fixtures/reject/src/lib.rs:196:2: overriding `Iterator::size_hint`, which std's adaptors call in place of `next` or beside it
`Pointer` formatting, as in `{:p}`, is not supported (1) -- fixtures/reject/src/lib.rs:75:3: `Pointer` formatting, as in `{:p}`, is not supported +- fixtures/reject/src/lib.rs:66:2: `Pointer` formatting, as in `{:p}`, is not supported
`_` holds `_`, which is `undefined` as `None` is, which is not supported (1) -- fixtures/reject/src/lib.rs:286:6: `std::collections::HashMap>` holds `std::option::Option`, which is `undefined` as `None` is, which is not supported +- fixtures/reject/src/lib.rs:276:6: `std::collections::HashMap>` holds `std::option::Option`, which is `undefined` as `None` is, which is not supported
`_` is not supported yet (1) -- fixtures/reject/src/lib.rs:408:18: `std::borrow::Cow<'_, [u8]>` is not supported yet +- fixtures/reject/src/lib.rs:398:18: `std::borrow::Cow<'_, [u8]>` is not supported yet
`_` of `_` by `_`, which is not supported yet (1) -- fixtures/reject/src/lib.rs:309:6: `HashMap::contains_key` of `std::collections::HashMap` by `u8`, which is not supported yet +- fixtures/reject/src/lib.rs:299:6: `HashMap::contains_key` of `std::collections::HashMap` by `u8`, which is not supported yet
@@ -355,79 +329,73 @@ The type or module each refused type or path belongs to.
`_` through a held type's own, which is not supported yet (1) -- fixtures/reject/src/lib.rs:341:2: ` as PartialEq>::ne` through a held type's own, which is not supported yet +- fixtures/reject/src/lib.rs:331:2: ` as PartialEq>::ne` through a held type's own, which is not supported yet
`_`, which is not supported yet (1) -- fixtures/reject/src/lib.rs:317:9: `Hasher::write`, which is not supported yet +- fixtures/reject/src/lib.rs:307:9: `Hasher::write`, which is not supported yet
`fold` of `_`, which folds a `flatten` whose source and iterators both drop, which is not supported yet (1) -- fixtures/reject/src/lib.rs:234:26: `fold` of `std::iter::Flatten>>`, which folds a `flatten` whose source and iterators both drop, which is not supported yet +- fixtures/reject/src/lib.rs:224:26: `fold` of `std::iter::Flatten>>`, which folds a `flatten` whose source and iterators both drop, which is not supported yet
a `_` cast from `_` to `_` (1) -- fixtures/reject/src/lib.rs:104:2: a `IntToFloat` cast from `u64` to `f64` +- fixtures/reject/src/lib.rs:94:2: a `IntToFloat` cast from `u64` to `f64`
a `zip` of `_` and `_`, which std reads by index, of items that drop, which is not supported yet (1) -- fixtures/reject/src/lib.rs:239:30: a `zip` of `std::iter::Map, {closure@fixtures/reject/src/lib.rs:239:15: 239:19}>` and `std::ops::Range`, which std reads by index, of items that drop, which is not supported yet +- fixtures/reject/src/lib.rs:229:30: a `zip` of `std::iter::Map, {closure@fixtures/reject/src/lib.rs:229:15: 229:19}>` and `std::ops::Range`, which std reads by index, of items that drop, which is not supported yet
a `zip` of `_`, whose closures std calls one item further through `next` than through `fold` (1) -- fixtures/reject/src/lib.rs:185:51: a `zip` of `std::iter::Chain, {closure@fixtures/reject/src/lib.rs:185:15: 185:18}>, std::iter::Copied>>`, whose closures std calls one item further through `next` than through `fold` +- fixtures/reject/src/lib.rs:175:51: a `zip` of `std::iter::Chain, {closure@fixtures/reject/src/lib.rs:175:15: 175:18}>, std::iter::Copied>>`, whose closures std calls one item further through `next` than through `fold`
a coercion to `_` (1) -- fixtures/reject/src/lib.rs:364:2: a coercion to `std::sync::Arc<[u8]>` +- fixtures/reject/src/lib.rs:354:2: a coercion to `std::sync::Arc<[u8]>`
a constant of type `_` (1) -- fixtures/reject/src/lib.rs:88:2: a constant of type `&u8` +- fixtures/reject/src/lib.rs:78:2: a constant of type `&u8`
a copy of a closure that changes what it captured (1) -- fixtures/reject/src/lib.rs:275:14: a copy of a closure that changes what it captured +- fixtures/reject/src/lib.rs:265:14: a copy of a closure that changes what it captured
a mutable borrow of a subslice of `_`, which JS would copy, having no views (1) -- fixtures/reject/src/lib.rs:244:13: a mutable borrow of a subslice of `u32`, which JS would copy, having no views +- fixtures/reject/src/lib.rs:234:13: a mutable borrow of a subslice of `u32`, which JS would copy, having no views
a mutable reference into a `Result`'s payload, passed on or kept (1) -- fixtures/reject/src/lib.rs:446:12: a mutable reference into a `Result`'s payload, passed on or kept - -
- -
a precision, as in `{:.2}`, is not supported (1) - -- fixtures/reject/src/lib.rs:67:3: a precision, as in `{:.2}`, is not supported +- fixtures/reject/src/lib.rs:436:12: a mutable reference into a `Result`'s payload, passed on or kept
a printable type must implement `Display` or `Debug` (1) -- fixtures/reject/src/lib.rs:100:1: a printable type must implement `Display` or `Debug` +- fixtures/reject/src/lib.rs:90:1: a printable type must implement `Display` or `Debug`
@@ -437,12 +405,6 @@ The type or module each refused type or path belongs to. -
a width or precision from an argument, as in `{:1$}`, is not supported (1) - -- fixtures/reject/src/lib.rs:74:3: a width or precision from an argument, as in `{:1$}`, is not supported - -
-
a zero-sized constant of type `_` (1) - fixtures/reject/src/lib.rs:60:2: a zero-sized constant of type `{async closure@fixtures/reject/src/lib.rs:59:10: 59:18}` @@ -451,7 +413,7 @@ The type or module each refused type or path belongs to.
an iterator that owns `_`, which drops, which is not supported yet (1) -- fixtures/reject/src/lib.rs:391:13: an iterator that owns `Noisy`, which drops, which is not supported yet +- fixtures/reject/src/lib.rs:381:13: an iterator that owns `Noisy`, which drops, which is not supported yet
@@ -463,36 +425,18 @@ The type or module each refused type or path belongs to.
comparing `_` as a key, which is not supported yet (1) -- fixtures/reject/src/lib.rs:291:52: comparing `std::vec::Vec` as a key, which is not supported yet +- fixtures/reject/src/lib.rs:281:52: comparing `std::vec::Vec` as a key, which is not supported yet
constructing `_` (1) -- fixtures/reject/src/lib.rs:415:53: constructing `std::borrow::Cow<'_, std::sync::Arc>` +- fixtures/reject/src/lib.rs:405:53: constructing `std::borrow::Cow<'_, std::sync::Arc>`
hashing `_` as a key, which is not supported yet (1) -- fixtures/reject/src/lib.rs:291:52: hashing `std::vec::Vec` as a key, which is not supported yet - -
- -
hex `Debug`, as in `{:x?}`, is not supported (1) - -- fixtures/reject/src/lib.rs:73:3: hex `Debug`, as in `{:x?}`, is not supported - -
- -
the `+` flag of a format spec is not supported (1) - -- fixtures/reject/src/lib.rs:68:3: the `+` flag of a format spec is not supported - -
- -
the `-` flag of a format spec is not supported (1) - -- fixtures/reject/src/lib.rs:69:3: the `-` flag of a format spec is not supported +- fixtures/reject/src/lib.rs:281:52: hashing `std::vec::Vec` as a key, which is not supported yet
diff --git a/ts/fixtures/reject/expected.txt b/ts/fixtures/reject/expected.txt index 6a5d50716..845a4f10a 100644 --- a/ts/fixtures/reject/expected.txt +++ b/ts/fixtures/reject/expected.txt @@ -1,6 +1,6 @@ -a root must not be generic at fixtures/reject/src/lib.rs:102:1 +a root must not be generic at fixtures/reject/src/lib.rs:92:1 no item `missing` in the crate -a printable type must implement `Display` or `Debug` at fixtures/reject/src/lib.rs:100:1 +a printable type must implement `Display` or `Debug` at fixtures/reject/src/lib.rs:90:1 unsupported type `f64` at fixtures/reject/src/lib.rs:7:14 a scalar constant of type `f64` at fixtures/reject/src/lib.rs:8:2 arithmetic on `f64` at fixtures/reject/src/lib.rs:8:2 @@ -17,70 +17,61 @@ passing `{closure@fixtures/reject/src/lib.rs:44:10: 44:23}`, a closure that owns dropping `std::iter::Map, {closure@fixtures/reject/src/lib.rs:44:10: 44:23}>`, which is not supported yet at fixtures/reject/src/lib.rs:45:18 `into_keys` of `std::collections::HashMap`, which drops `Noisy`, which is not supported yet at fixtures/reject/src/lib.rs:51:13 a zero-sized constant of type `{async closure@fixtures/reject/src/lib.rs:59:10: 59:18}` at fixtures/reject/src/lib.rs:60:2 -a precision, as in `{:.2}`, is not supported at fixtures/reject/src/lib.rs:67:3 -the `+` flag of a format spec is not supported at fixtures/reject/src/lib.rs:68:3 -the `-` flag of a format spec is not supported at fixtures/reject/src/lib.rs:69:3 -`Binary` formatting, as in `{:b}`, is not supported at fixtures/reject/src/lib.rs:70:12 -`Octal` formatting, as in `{:o}`, is not supported at fixtures/reject/src/lib.rs:71:12 -`LowerExp` formatting, as in `{:e}`, is not supported at fixtures/reject/src/lib.rs:72:12 -hex `Debug`, as in `{:x?}`, is not supported at fixtures/reject/src/lib.rs:73:3 -a width or precision from an argument, as in `{:1$}`, is not supported at fixtures/reject/src/lib.rs:74:15 -a width or precision from an argument, as in `{:1$}`, is not supported at fixtures/reject/src/lib.rs:74:3 -`Pointer` formatting, as in `{:p}`, is not supported at fixtures/reject/src/lib.rs:75:12 -unsupported call to `::write_fmt` at fixtures/reject/src/lib.rs:82:10 -a constant of type `&u8` at fixtures/reject/src/lib.rs:88:2 -replacing the value behind a reference to `Meters` at fixtures/reject/src/lib.rs:93:2 -replacing the value behind a reference to `Meters` at fixtures/reject/src/lib.rs:97:2 -an assignment through a reference to `std::sync::Arc` at fixtures/reject/src/lib.rs:109:2 -`Poll>>` is not supported: it would be pending two ways with one value at fixtures/reject/src/lib.rs:113:20 -`Option>` is not supported: its `None` and `Some` would both be `undefined` at fixtures/reject/src/lib.rs:118:19 -`Poll>` is not supported: it would be pending two ways with one value at fixtures/reject/src/lib.rs:123:54 -an assignment through a reference to `std::pin::Pin>` at fixtures/reject/src/lib.rs:129:2 -an assignment through a reference to `std::sync::MutexGuard<'_, u8>` at fixtures/reject/src/lib.rs:134:2 -unsupported call to ` as std::iter::Iterator>::cycle` at fixtures/reject/src/lib.rs:139:11 -constructing `std::iter::Map` from another crate at fixtures/reject/src/lib.rs:158:23 -constructing `std::iter::Rev` from another crate at fixtures/reject/src/lib.rs:179:14 -a `zip` of `std::iter::Chain, {closure@fixtures/reject/src/lib.rs:185:15: 185:18}>, std::iter::Copied>>`, whose closures std calls one item further through `next` than through `fold` at fixtures/reject/src/lib.rs:185:51 -unsupported call to `std::ops::Range::::contains::` at fixtures/reject/src/lib.rs:193:8 -`fold` of `std::iter::Flatten>>`, which folds a `flatten` whose source and iterators both drop, which is not supported yet at fixtures/reject/src/lib.rs:234:26 -a `zip` of `std::iter::Map, {closure@fixtures/reject/src/lib.rs:239:15: 239:19}>` and `std::ops::Range`, which std reads by index, of items that drop, which is not supported yet at fixtures/reject/src/lib.rs:239:30 -a mutable borrow of a subslice of `u32`, which JS would copy, having no views at fixtures/reject/src/lib.rs:244:13 -an assignment through a reference to `std::pin::Pin<&mut Noisy>` at fixtures/reject/src/lib.rs:252:2 -replacing the value behind a reference to `[u16; 1]` at fixtures/reject/src/lib.rs:258:22 -`std::iter::Iterator::filter` of a reference to an array of bytes it is generic over, which its mapping would take as the array, not as a slice of it at fixtures/reject/src/lib.rs:265:16 -`std::iter::Iterator::count` of a reference to an array of bytes it is generic over, which its mapping would take as the array, not as a slice of it at fixtures/reject/src/lib.rs:265:38 -a copy of a closure that changes what it captured at fixtures/reject/src/lib.rs:275:14 -a field of `std::ops::RangeTo` at fixtures/reject/src/lib.rs:281:7 -a field of `std::ops::RangeFrom` at fixtures/reject/src/lib.rs:281:48 -`Option<&std::option::Option>` is not supported: its `None` and `Some` would both be `undefined` at fixtures/reject/src/lib.rs:286:2 -`std::collections::HashMap>` holds `std::option::Option`, which is `undefined` as `None` is, which is not supported at fixtures/reject/src/lib.rs:286:6 -hashing `std::vec::Vec` as a key, which is not supported yet at fixtures/reject/src/lib.rs:291:52 -comparing `std::vec::Vec` as a key, which is not supported yet at fixtures/reject/src/lib.rs:291:52 -`HashMap::contains_key` of `std::collections::HashMap` by `u8`, which is not supported yet at fixtures/reject/src/lib.rs:309:6 -unsupported call to `core::slice::::copy_within::>` at fixtures/reject/src/lib.rs:359:4 -a coercion to `std::sync::Arc<[u8]>` at fixtures/reject/src/lib.rs:364:2 -a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string at fixtures/reject/src/lib.rs:397:2 -a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string at fixtures/reject/src/lib.rs:399:27 -a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string at fixtures/reject/src/lib.rs:398:30 -a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string at fixtures/reject/src/lib.rs:404:2 -`std::borrow::Cow<'_, [u8]>` is not supported yet at fixtures/reject/src/lib.rs:408:18 -unsupported call to ` as std::ops::Deref>::deref` at fixtures/reject/src/lib.rs:409:2 -constructing `std::borrow::Cow<'_, std::sync::Arc>` at fixtures/reject/src/lib.rs:415:53 -unsupported call to `core::str::::split::<[char; 2]>` at fixtures/reject/src/lib.rs:370:4 -passing `{closure@fixtures/reject/src/lib.rs:380:28: 380:35}`, a closure that owns a value that drops, to `Entry::or_insert_with`, which is not supported yet at fixtures/reject/src/lib.rs:380:13 -passing `{closure@fixtures/reject/src/lib.rs:381:15: 381:24}`, a closure that owns a value that drops, to `Iterator::any`, which is not supported yet at fixtures/reject/src/lib.rs:381:11 -passing `{closure@fixtures/reject/src/lib.rs:389:48: 389:56}`, a closure that owns a value that drops, to `successors::successors`, which is not supported yet at fixtures/reject/src/lib.rs:389:15 -dropping `std::iter::Take>`, which is not supported yet at fixtures/reject/src/lib.rs:389:79 -passing `{closure@fixtures/reject/src/lib.rs:390:32: 390:39}`, a closure that owns a value that drops, to `from_fn::from_fn`, which is not supported yet at fixtures/reject/src/lib.rs:390:13 -dropping `std::iter::Take>`, which is not supported yet at fixtures/reject/src/lib.rs:390:62 -an iterator that owns `Noisy`, which drops, which is not supported yet at fixtures/reject/src/lib.rs:391:13 -unsupported call to `::add_assign` at fixtures/reject/src/lib.rs:423:2 -`core::slice::::last_mut` with a mutable reference to a value JS copies, which its mapping would copy at fixtures/reject/src/lib.rs:429:21 -`std::collections::hash_map::Entry::<'a, K, V, A>::and_modify` with a mutable reference to a value JS copies, which its mapping would copy at fixtures/reject/src/lib.rs:436:15 -a mutable reference into a `Result`'s payload, passed on or kept at fixtures/reject/src/lib.rs:446:12 -unsupported call to ` as std::cmp::PartialEq>::eq` at fixtures/reject/src/lib.rs:453:2 -overriding `Iterator::fold`, which std's adaptors call in place of `next` or beside it at fixtures/reject/src/lib.rs:152:2 -an iterator of the crate implementing `DoubleEndedIterator`, which is not supported yet at fixtures/reject/src/lib.rs:172:1 -overriding `Iterator::size_hint`, which std's adaptors call in place of `next` or beside it at fixtures/reject/src/lib.rs:206:2 -an iterator of the crate implementing `FusedIterator`, which is not supported yet at fixtures/reject/src/lib.rs:226:1 -`Hasher::write`, which is not supported yet at fixtures/reject/src/lib.rs:317:9 +`Pointer` formatting, as in `{:p}`, is not supported at fixtures/reject/src/lib.rs:66:11 +unsupported call to `::write_fmt` at fixtures/reject/src/lib.rs:72:10 +a constant of type `&u8` at fixtures/reject/src/lib.rs:78:2 +replacing the value behind a reference to `Meters` at fixtures/reject/src/lib.rs:83:2 +replacing the value behind a reference to `Meters` at fixtures/reject/src/lib.rs:87:2 +an assignment through a reference to `std::sync::Arc` at fixtures/reject/src/lib.rs:99:2 +`Poll>>` is not supported: it would be pending two ways with one value at fixtures/reject/src/lib.rs:103:20 +`Option>` is not supported: its `None` and `Some` would both be `undefined` at fixtures/reject/src/lib.rs:108:19 +`Poll>` is not supported: it would be pending two ways with one value at fixtures/reject/src/lib.rs:113:54 +an assignment through a reference to `std::pin::Pin>` at fixtures/reject/src/lib.rs:119:2 +an assignment through a reference to `std::sync::MutexGuard<'_, u8>` at fixtures/reject/src/lib.rs:124:2 +unsupported call to ` as std::iter::Iterator>::cycle` at fixtures/reject/src/lib.rs:129:11 +constructing `std::iter::Map` from another crate at fixtures/reject/src/lib.rs:148:23 +constructing `std::iter::Rev` from another crate at fixtures/reject/src/lib.rs:169:14 +a `zip` of `std::iter::Chain, {closure@fixtures/reject/src/lib.rs:175:15: 175:18}>, std::iter::Copied>>`, whose closures std calls one item further through `next` than through `fold` at fixtures/reject/src/lib.rs:175:51 +unsupported call to `std::ops::Range::::contains::` at fixtures/reject/src/lib.rs:183:8 +`fold` of `std::iter::Flatten>>`, which folds a `flatten` whose source and iterators both drop, which is not supported yet at fixtures/reject/src/lib.rs:224:26 +a `zip` of `std::iter::Map, {closure@fixtures/reject/src/lib.rs:229:15: 229:19}>` and `std::ops::Range`, which std reads by index, of items that drop, which is not supported yet at fixtures/reject/src/lib.rs:229:30 +a mutable borrow of a subslice of `u32`, which JS would copy, having no views at fixtures/reject/src/lib.rs:234:13 +an assignment through a reference to `std::pin::Pin<&mut Noisy>` at fixtures/reject/src/lib.rs:242:2 +replacing the value behind a reference to `[u16; 1]` at fixtures/reject/src/lib.rs:248:22 +`std::iter::Iterator::filter` of a reference to an array of bytes it is generic over, which its mapping would take as the array, not as a slice of it at fixtures/reject/src/lib.rs:255:16 +`std::iter::Iterator::count` of a reference to an array of bytes it is generic over, which its mapping would take as the array, not as a slice of it at fixtures/reject/src/lib.rs:255:38 +a copy of a closure that changes what it captured at fixtures/reject/src/lib.rs:265:14 +a field of `std::ops::RangeTo` at fixtures/reject/src/lib.rs:271:7 +a field of `std::ops::RangeFrom` at fixtures/reject/src/lib.rs:271:48 +`Option<&std::option::Option>` is not supported: its `None` and `Some` would both be `undefined` at fixtures/reject/src/lib.rs:276:2 +`std::collections::HashMap>` holds `std::option::Option`, which is `undefined` as `None` is, which is not supported at fixtures/reject/src/lib.rs:276:6 +hashing `std::vec::Vec` as a key, which is not supported yet at fixtures/reject/src/lib.rs:281:52 +comparing `std::vec::Vec` as a key, which is not supported yet at fixtures/reject/src/lib.rs:281:52 +`HashMap::contains_key` of `std::collections::HashMap` by `u8`, which is not supported yet at fixtures/reject/src/lib.rs:299:6 +unsupported call to `core::slice::::copy_within::>` at fixtures/reject/src/lib.rs:349:4 +a coercion to `std::sync::Arc<[u8]>` at fixtures/reject/src/lib.rs:354:2 +a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string at fixtures/reject/src/lib.rs:387:2 +a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string at fixtures/reject/src/lib.rs:389:27 +a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string at fixtures/reject/src/lib.rs:388:30 +a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string at fixtures/reject/src/lib.rs:394:2 +`std::borrow::Cow<'_, [u8]>` is not supported yet at fixtures/reject/src/lib.rs:398:18 +unsupported call to ` as std::ops::Deref>::deref` at fixtures/reject/src/lib.rs:399:2 +constructing `std::borrow::Cow<'_, std::sync::Arc>` at fixtures/reject/src/lib.rs:405:53 +unsupported call to `core::str::::split::<[char; 2]>` at fixtures/reject/src/lib.rs:360:4 +passing `{closure@fixtures/reject/src/lib.rs:370:28: 370:35}`, a closure that owns a value that drops, to `Entry::or_insert_with`, which is not supported yet at fixtures/reject/src/lib.rs:370:13 +passing `{closure@fixtures/reject/src/lib.rs:371:15: 371:24}`, a closure that owns a value that drops, to `Iterator::any`, which is not supported yet at fixtures/reject/src/lib.rs:371:11 +passing `{closure@fixtures/reject/src/lib.rs:379:48: 379:56}`, a closure that owns a value that drops, to `successors::successors`, which is not supported yet at fixtures/reject/src/lib.rs:379:15 +dropping `std::iter::Take>`, which is not supported yet at fixtures/reject/src/lib.rs:379:79 +passing `{closure@fixtures/reject/src/lib.rs:380:32: 380:39}`, a closure that owns a value that drops, to `from_fn::from_fn`, which is not supported yet at fixtures/reject/src/lib.rs:380:13 +dropping `std::iter::Take>`, which is not supported yet at fixtures/reject/src/lib.rs:380:62 +an iterator that owns `Noisy`, which drops, which is not supported yet at fixtures/reject/src/lib.rs:381:13 +unsupported call to `::add_assign` at fixtures/reject/src/lib.rs:413:2 +`core::slice::::last_mut` with a mutable reference to a value JS copies, which its mapping would copy at fixtures/reject/src/lib.rs:419:21 +`std::collections::hash_map::Entry::<'a, K, V, A>::and_modify` with a mutable reference to a value JS copies, which its mapping would copy at fixtures/reject/src/lib.rs:426:15 +a mutable reference into a `Result`'s payload, passed on or kept at fixtures/reject/src/lib.rs:436:12 +unsupported call to ` as std::cmp::PartialEq>::eq` at fixtures/reject/src/lib.rs:443:2 +overriding `Iterator::fold`, which std's adaptors call in place of `next` or beside it at fixtures/reject/src/lib.rs:142:2 +an iterator of the crate implementing `DoubleEndedIterator`, which is not supported yet at fixtures/reject/src/lib.rs:162:1 +overriding `Iterator::size_hint`, which std's adaptors call in place of `next` or beside it at fixtures/reject/src/lib.rs:196:2 +an iterator of the crate implementing `FusedIterator`, which is not supported yet at fixtures/reject/src/lib.rs:216:1 +`Hasher::write`, which is not supported yet at fixtures/reject/src/lib.rs:307:9 diff --git a/ts/fixtures/reject/src/lib.rs b/ts/fixtures/reject/src/lib.rs index 68cdbd1e6..6e2e75096 100644 --- a/ts/fixtures/reject/src/lib.rs +++ b/ts/fixtures/reject/src/lib.rs @@ -61,19 +61,9 @@ pub fn async_closure() -> u8 { 0 } -/// Format specs outside what moq uses. -pub fn specs(n: u8, w: usize) -> [String; 9] { - [ - format!("{n:.2}"), - format!("{n:+}"), - format!("{n:-}"), - format!("{n:b}"), - format!("{n:o}"), - format!("{n:e}"), - format!("{n:x?}"), - format!("{n:w$}"), - format!("{:p}", &n), - ] +/// A pointer's address, which JS has no counterpart of. +pub fn pointer(n: u8) -> String { + format!("{:p}", &n) } /// `fmt::Write` for a `String`, which has no mapping. diff --git a/ts/fixtures/reject/ts.toml b/ts/fixtures/reject/ts.toml index 5765d60e8..92864e9a7 100644 --- a/ts/fixtures/reject/ts.toml +++ b/ts/fixtures/reject/ts.toml @@ -10,7 +10,7 @@ roots = [ "owning_closure", "keys", "async_closure", - "specs", + "pointer", "written", "statics", "swapped", diff --git a/ts/fixtures/task/expected/drops.Key.ts b/ts/fixtures/task/expected/drops.Key.ts index 2b6777d3f..1dbed1d67 100644 --- a/ts/fixtures/task/expected/drops.Key.ts +++ b/ts/fixtures/task/expected/drops.Key.ts @@ -102,7 +102,7 @@ export function hash$Hash_DefaultHasher(self: Key, state: rt.Hasher): void { } export function fmt$Debug(self: Key, f: rt.Formatter): rt.Result { - return rt.debugTupleFinish(rt.debugTupleField(rt.fmtDebugTuple(f, "Key"), (f: rt.Formatter) => rt.u32Display(self.id, f))); + return rt.debugTupleFinish(rt.debugTupleField(rt.fmtDebugTuple(f, "Key"), (f: rt.Formatter) => rt.u32Debug(self.id, f))); } export { new_ as new }; diff --git a/ts/fixtures/task/expected/drops/closures.ts b/ts/fixtures/task/expected/drops/closures.ts index ece40ccd6..d1fec3ee3 100644 --- a/ts/fixtures/task/expected/drops/closures.ts +++ b/ts/fixtures/task/expected/drops/closures.ts @@ -479,7 +479,7 @@ export function discarded(log: Log.Log, id: rt.u32, at: rt.u8): void { }, (): void => { rt.drop(captured3); })); - const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(mapped, f, rt.u32Display), (f: rt.Formatter) => rt.fmtOption(unmapped, f, rt.u32Display)]; + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(mapped, f, rt.u32Debug), (f: rt.Formatter) => rt.fmtOption(unmapped, f, rt.u32Debug)]; Log.note(log, rt.fmtFormat(["map ", args2[0], " ", args2[1]])); const ok: rt.Result = rt.Ok(id); const err: rt.Result = rt.Err(id); @@ -581,7 +581,7 @@ export function discarded(log: Log.Log, id: rt.u32, at: rt.u8): void { }, (): void => { rt.drop(captured8); }))]; - const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtResult(values[0], f, rt.u32Display, rt.u32Display), (f: rt.Formatter) => rt.fmtResult(values[1], f, rt.u32Display, rt.u32Display)], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtResult(errors[0], f, rt.u32Display, rt.u32Display), (f: rt.Formatter) => rt.fmtResult(errors[1], f, rt.u32Display, rt.u32Display)], f)]; + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtResult(values[0], f, rt.u32Debug, rt.u32Debug), (f: rt.Formatter) => rt.fmtResult(values[1], f, rt.u32Debug, rt.u32Debug)], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtResult(errors[0], f, rt.u32Debug, rt.u32Debug), (f: rt.Formatter) => rt.fmtResult(errors[1], f, rt.u32Debug, rt.u32Debug)], f)]; Log.note(log, rt.fmtFormat(["result ", args4[0], " ", args4[1]])); _84 = guard(7); unwind = 106; @@ -685,7 +685,7 @@ export function discarded(log: Log.Log, id: rt.u32, at: rt.u8): void { }, (): void => { rt.drop(captured13); }))]; - const args6: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtResult(chained[0], f, rt.u32Display, rt.u32Display), (f: rt.Formatter) => rt.fmtResult(chained[1], f, rt.u32Display, rt.u32Display)], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtResult(inspected[0], f, rt.u32Display, rt.u32Display), (f: rt.Formatter) => rt.fmtResult(inspected[1], f, rt.u32Display, rt.u32Display)], f)]; + const args6: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtResult(chained[0], f, rt.u32Debug, rt.u32Debug), (f: rt.Formatter) => rt.fmtResult(chained[1], f, rt.u32Debug, rt.u32Debug)], f), (f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtResult(inspected[0], f, rt.u32Debug, rt.u32Debug), (f: rt.Formatter) => rt.fmtResult(inspected[1], f, rt.u32Debug, rt.u32Debug)], f)]; Log.note(log, rt.fmtFormat(["chained ", args6[0], " ", args6[1]])); _124 = guard(11); unwind = 102; @@ -738,7 +738,7 @@ export function discarded(log: Log.Log, id: rt.u32, at: rt.u8): void { }, (): void => { rt.drop(captured16); }))] as [rt.u32, rt.u32]; - const args8: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.u32Display(part3[0], f), (f: rt.Formatter) => rt.u32Display(part3[1], f)], f)]; + const args8: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.u32Debug(part3[0], f), (f: rt.Formatter) => rt.u32Debug(part3[1], f)], f)]; Log.note(log, rt.fmtFormat(["map_or ", args8[0]])); _150 = guard(13); unwind = 100; @@ -789,7 +789,7 @@ export function discarded(log: Log.Log, id: rt.u32, at: rt.u8): void { }, (): void => { rt.drop(captured18); }), rt.drop)] as [rt.u32 | undefined, rt.u32 | undefined]; - const args10: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtOption(part4[0], f, rt.u32Display), (f: rt.Formatter) => rt.fmtOption(part4[1], f, rt.u32Display)], f)]; + const args10: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.fmtOption(part4[0], f, rt.u32Debug), (f: rt.Formatter) => rt.fmtOption(part4[1], f, rt.u32Debug)], f)]; Log.note(log, rt.fmtFormat(["then ", args10[0]])); _177 = guard(15); unwind = 98; @@ -819,7 +819,7 @@ export function discarded(log: Log.Log, id: rt.u32, at: rt.u8): void { const _191: rt.u32 | undefined = map$Option_u32_u32_discarded_closure16(some, plus); _265 = false; const _194: rt.u32 | undefined = map$Option_u32_u32_discarded_closure16(none, other); - const args12: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(_191, f, rt.u32Display), (f: rt.Formatter) => rt.fmtOption(_194, f, rt.u32Display)]; + const args12: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(_191, f, rt.u32Debug), (f: rt.Formatter) => rt.fmtOption(_194, f, rt.u32Debug)]; Log.note(log, rt.fmtFormat(["by ref ", args12[0], " ", args12[1]])); _205 = guard(18); unwind = 95; @@ -846,7 +846,7 @@ export function discarded(log: Log.Log, id: rt.u32, at: rt.u8): void { })), rt.drop); _262 = false; const _221: rt.u32 | undefined = rt.boolThen(!yes, rt.once(skipped), rt.drop); - const args14: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(_219, f, rt.u32Display), (f: rt.Formatter) => rt.fmtOption(_221, f, rt.u32Display)]; + const args14: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(_219, f, rt.u32Debug), (f: rt.Formatter) => rt.fmtOption(_221, f, rt.u32Debug)]; Log.note(log, rt.fmtFormat(["then by ref ", args14[0], " ", args14[1]])); const captured24 = guard(17); const _240: rt.u32 | undefined = some; @@ -875,7 +875,7 @@ export function discarded(log: Log.Log, id: rt.u32, at: rt.u8): void { }, (): void => { rt.drop(captured26); })); - const args16: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(part5, f, rt.u32Display)]; + const args16: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(part5, f, rt.u32Debug)]; Log.note(log, rt.fmtFormat(["nested ", args16[0]])); check(7); _262 = false; diff --git a/ts/runtime/rt.ts b/ts/runtime/rt.ts index 91dac163b..adc50d784 100644 --- a/ts/runtime/rt.ts +++ b/ts/runtime/rt.ts @@ -5,7 +5,7 @@ // left only where a call dispatches on its receiver: an iterator's `next`, a writer's // `writeStr`, a future's `poll`, a waker's, and `[Symbol.dispose]`. -import { type char, type TryFromIntError, type u32, u8Display, usizeDisplay } from "./rt/int.ts"; +import { type char, type TryFromIntError, type u32, u8Debug, usizeDebug, usizeDisplay } from "./rt/int.ts"; import type { Pending } from "./rt/task.ts"; export * from "./rt/collections.ts"; @@ -556,11 +556,36 @@ export type Arguments = readonly (string | Fmt)[]; export interface Spec { readonly fill?: string; readonly align?: "<" | "^" | ">"; + /** The `+` flag: a sign on a nonnegative number too. */ + readonly plus?: boolean; /** The `#` flag: `{:#?}` and `{:#x}`. */ readonly alternate?: boolean; /** The `0` flag: zeros between the sign and the digits. */ readonly zero?: boolean; + /** `{:x?}` or `{:X?}`: an integer's `Debug` in hex. */ + readonly debugHex?: "x" | "X"; readonly width?: number; + /** The `.N` of `{:.N}`: the most chars `pad` writes, or digits past a number's point. */ + readonly precision?: number; +} + +/** A width or precision from an argument, as in `{:1$}`: a `fmt::rt::Argument` only a spec reads. */ +export interface Count extends Fmt { + readonly count: number; +} + +/** `Argument::from_usize`: `n` as a width or precision, panicking past what one holds. */ +export function fmtCount(n: number): Count { + if (n > 0xffff) panic("Formatting argument out of range"); + const unreachable = (): never => { + throw new Error("rust2-ts: a width or precision written as a placeholder"); + }; + return Object.assign(unreachable, { count: n }); +} + +/** The width or precision `argument`, a `Count`, holds. */ +export function fmtCountOf(argument: Fmt): number { + return (argument as Count).count; } /** `dyn fmt::Write`: where a `Formatter` writes. */ @@ -643,17 +668,29 @@ export function fmtWidth(f: Formatter): number | undefined { return f.spec.width; } -/** Write `s`, padded to the width. */ +/** Write `s`, cut to the precision in chars, padded to the width. */ export function fmtPad(f: Formatter, s: string): FmtResult { - const width = f.spec.width; - const count = width === undefined ? 0 : chars(s); + const { width, precision } = f.spec; + if (width === undefined && precision === undefined) return f.out.writeStr(s); + let count = 0; + if (precision === undefined) { + count = chars(s); + } else { + let end = 0; + for (const c of s) { + if (count === precision) break; + end += c.length; + count++; + } + s = s.slice(0, end); + } if (width === undefined || count >= width) return f.out.writeStr(s); return padded(f, width - count, f.spec.align ?? "<", f.spec.fill ?? " ", s); } /** Write an integer's sign, `prefix` if alternate, and `digits`, padded to the width. */ export function fmtPadIntegral(f: Formatter, nonnegative: boolean, prefix: string, digits: string): FmtResult { - const head = (nonnegative ? "" : "-") + (fmtAlternate(f) ? prefix : ""); + const head = (nonnegative ? (f.spec.plus ? "+" : "") : "-") + (fmtAlternate(f) ? prefix : ""); const length = head.length + digits.length; const width = f.spec.width ?? 0; if (length >= width) return f.out.writeStr(head + digits); @@ -975,14 +1012,14 @@ export function fmtFromUtf8ErrorDebug(e: FromUtf8Error, f: Formatter): FmtResult const error: Fmt = (f) => debugStructFinish( debugStructField( - debugStructField(fmtDebugStruct(f, "Utf8Error"), "valid_up_to", (f) => usizeDisplay(e.validUpTo, f)), + debugStructField(fmtDebugStruct(f, "Utf8Error"), "valid_up_to", (f) => usizeDebug(e.validUpTo, f)), "error_len", - (f) => fmtOption(e.errorLen, f, u8Display), + (f) => fmtOption(e.errorLen, f, u8Debug), ), ); return debugStructFinish( debugStructField( - debugStructField(fmtDebugStruct(f, "FromUtf8Error"), "bytes", (f) => fmtList(byteVecView(e.bytes), f, u8Display)), + debugStructField(fmtDebugStruct(f, "FromUtf8Error"), "bytes", (f) => fmtList(byteVecView(e.bytes), f, u8Debug)), "error", error, ), diff --git a/ts/runtime/rt/int.ts b/ts/runtime/rt/int.ts index 31c67ba2d..176f7f1cc 100644 --- a/ts/runtime/rt/int.ts +++ b/ts/runtime/rt/int.ts @@ -174,17 +174,58 @@ function narrowStep(n: number, by: number, min: number, max: number, wrap: (v: n return v >= min && v <= max ? [v, false] : [wrap(v), true]; } -/** `Display` and `Debug` of an integer in a number, which write the same. */ +/** `Display` of an integer in a number. */ function display(a: number, f: Formatter): FmtResult { return fmtPadIntegral(f, a >= 0, "", String(a < 0 ? -a : a)); } +/** `Debug` of `a`, an integer in a number whose bits as unsigned are `bits`. */ +function debug(a: number, bits: number, f: Formatter): FmtResult { + const hexDigits = f.spec.debugHex; + return hexDigits === undefined ? display(a, f) : hex(bits, f, hexDigits === "X"); +} + /** `LowerHex` or `UpperHex` of `bits`, a value's bits as unsigned. */ function hex(bits: number | bigint, f: Formatter, upper: boolean): FmtResult { const digits = bits.toString(16); return fmtPadIntegral(f, true, "0x", upper ? digits.toUpperCase() : digits); } +/** `Binary` or `Octal` of `bits`, a value's bits as unsigned. */ +function radix(bits: number | bigint, f: Formatter, base: 2 | 8, prefix: "0b" | "0o"): FmtResult { + return fmtPadIntegral(f, true, prefix, bits.toString(base)); +} + +/** + * `LowerExp` or `UpperExp` of an integer, from its sign and its magnitude's decimal + * `digits`: rounded half to even to the precision, else without trailing zeros. + */ +function exp(nonnegative: boolean, digits: string, f: Formatter, letter: "e" | "E"): FmtResult { + let exponent = digits.length - 1; + // The significant digits, the first before the point, and the zeros after them. + let coef = digits; + let zeros = 0; + const precision = f.spec.precision; + if (precision === undefined) { + coef = digits.replace(/(?<=.)0+$/, ""); + } else if (precision >= exponent) { + zeros = precision - exponent; + } else { + coef = digits.slice(0, precision + 1); + const over = digits.slice(precision + 1); + const tie = over[0] === "5" && !/[1-9]/.test(over.slice(1)); + const up = tie ? Number(coef[coef.length - 1]) % 2 === 1 : over[0]! >= "5"; + if (up) coef = String(BigInt(coef) + 1n); + // Rounding 9s up carries into one more digit: a power of ten higher. + if (coef.length > precision + 1) { + coef = coef.slice(0, -1); + exponent++; + } + } + const point = coef.length > 1 || zeros > 0 ? `.${coef.slice(1)}${"0".repeat(zeros)}` : ""; + return fmtPadIntegral(f, nonnegative, "", `${coef[0]}${point}${letter}${exponent}`); +} + const wrapU8 = (v: number) => v & 0xff; const wrapU16 = (v: number) => v & 0xffff; const wrapU32 = (v: number) => v >>> 0; @@ -234,6 +275,16 @@ export const u8TryFrom = (value: number | Limbs): Result => export const u8LowerHex = (a: u8, f: Formatter): FmtResult => hex(a, f, false); /** `u8`'s `UpperHex`, `{:X}`. */ export const u8UpperHex = (a: u8, f: Formatter): FmtResult => hex(a, f, true); +/** `u8`'s `Debug`, `Display` unless `{:x?}` or `{:X?}` makes it hex. */ +export const u8Debug = (a: u8, f: Formatter): FmtResult => debug(a, a, f); +/** `u8`'s `Binary`, `{:b}`. */ +export const u8Binary = (a: u8, f: Formatter): FmtResult => radix(a, f, 2, "0b"); +/** `u8`'s `Octal`, `{:o}`. */ +export const u8Octal = (a: u8, f: Formatter): FmtResult => radix(a, f, 8, "0o"); +/** `u8`'s `LowerExp`, `{:e}`. */ +export const u8LowerExp = (a: u8, f: Formatter): FmtResult => exp(a >= 0, String(Math.abs(a)), f, "e"); +/** `u8`'s `UpperExp`, `{:E}`. */ +export const u8UpperExp = (a: u8, f: Formatter): FmtResult => exp(a >= 0, String(Math.abs(a)), f, "E"); /** `u8`'s `Step`, which ranges step by: `n` moved by `by`, and whether that overflowed. */ export const u8Step: Step = (n, by) => narrowStep(n, by, 0, 0xff, wrapU8); @@ -279,6 +330,16 @@ export const u16TryFrom = (value: number | Limbs): Result export const u16LowerHex = (a: u16, f: Formatter): FmtResult => hex(a, f, false); /** `u16`'s `UpperHex`, `{:X}`. */ export const u16UpperHex = (a: u16, f: Formatter): FmtResult => hex(a, f, true); +/** `u16`'s `Debug`, `Display` unless `{:x?}` or `{:X?}` makes it hex. */ +export const u16Debug = (a: u16, f: Formatter): FmtResult => debug(a, a, f); +/** `u16`'s `Binary`, `{:b}`. */ +export const u16Binary = (a: u16, f: Formatter): FmtResult => radix(a, f, 2, "0b"); +/** `u16`'s `Octal`, `{:o}`. */ +export const u16Octal = (a: u16, f: Formatter): FmtResult => radix(a, f, 8, "0o"); +/** `u16`'s `LowerExp`, `{:e}`. */ +export const u16LowerExp = (a: u16, f: Formatter): FmtResult => exp(a >= 0, String(Math.abs(a)), f, "e"); +/** `u16`'s `UpperExp`, `{:E}`. */ +export const u16UpperExp = (a: u16, f: Formatter): FmtResult => exp(a >= 0, String(Math.abs(a)), f, "E"); /** `u16`'s `Step`, which ranges step by: `n` moved by `by`, and whether that overflowed. */ export const u16Step: Step = (n, by) => narrowStep(n, by, 0, 0xffff, wrapU16); @@ -324,6 +385,16 @@ export const u32TryFrom = (value: number | Limbs): Result export const u32LowerHex = (a: u32, f: Formatter): FmtResult => hex(a, f, false); /** `u32`'s `UpperHex`, `{:X}`. */ export const u32UpperHex = (a: u32, f: Formatter): FmtResult => hex(a, f, true); +/** `u32`'s `Debug`, `Display` unless `{:x?}` or `{:X?}` makes it hex. */ +export const u32Debug = (a: u32, f: Formatter): FmtResult => debug(a, a, f); +/** `u32`'s `Binary`, `{:b}`. */ +export const u32Binary = (a: u32, f: Formatter): FmtResult => radix(a, f, 2, "0b"); +/** `u32`'s `Octal`, `{:o}`. */ +export const u32Octal = (a: u32, f: Formatter): FmtResult => radix(a, f, 8, "0o"); +/** `u32`'s `LowerExp`, `{:e}`. */ +export const u32LowerExp = (a: u32, f: Formatter): FmtResult => exp(a >= 0, String(Math.abs(a)), f, "e"); +/** `u32`'s `UpperExp`, `{:E}`. */ +export const u32UpperExp = (a: u32, f: Formatter): FmtResult => exp(a >= 0, String(Math.abs(a)), f, "E"); /** `u32`'s `Step`, which ranges step by: `n` moved by `by`, and whether that overflowed. */ export const u32Step: Step = (n, by) => narrowStep(n, by, 0, 0xffffffff, wrapU32); @@ -371,6 +442,16 @@ export const i8TryFrom = (value: number | Limbs): Result => export const i8LowerHex = (a: i8, f: Formatter): FmtResult => hex(a & 0xff, f, false); /** `i8`'s `UpperHex`, `{:X}`. */ export const i8UpperHex = (a: i8, f: Formatter): FmtResult => hex(a & 0xff, f, true); +/** `i8`'s `Debug`, `Display` unless `{:x?}` or `{:X?}` makes it hex. */ +export const i8Debug = (a: i8, f: Formatter): FmtResult => debug(a, a & 0xff, f); +/** `i8`'s `Binary`, `{:b}`. */ +export const i8Binary = (a: i8, f: Formatter): FmtResult => radix(a & 0xff, f, 2, "0b"); +/** `i8`'s `Octal`, `{:o}`. */ +export const i8Octal = (a: i8, f: Formatter): FmtResult => radix(a & 0xff, f, 8, "0o"); +/** `i8`'s `LowerExp`, `{:e}`. */ +export const i8LowerExp = (a: i8, f: Formatter): FmtResult => exp(a >= 0, String(Math.abs(a)), f, "e"); +/** `i8`'s `UpperExp`, `{:E}`. */ +export const i8UpperExp = (a: i8, f: Formatter): FmtResult => exp(a >= 0, String(Math.abs(a)), f, "E"); /** `i8`'s `Step`, which ranges step by: `n` moved by `by`, and whether that overflowed. */ export const i8Step: Step = (n, by) => narrowStep(n, by, -0x80, 0x7f, wrapI8); @@ -418,6 +499,16 @@ export const i16TryFrom = (value: number | Limbs): Result export const i16LowerHex = (a: i16, f: Formatter): FmtResult => hex(a & 0xffff, f, false); /** `i16`'s `UpperHex`, `{:X}`. */ export const i16UpperHex = (a: i16, f: Formatter): FmtResult => hex(a & 0xffff, f, true); +/** `i16`'s `Debug`, `Display` unless `{:x?}` or `{:X?}` makes it hex. */ +export const i16Debug = (a: i16, f: Formatter): FmtResult => debug(a, a & 0xffff, f); +/** `i16`'s `Binary`, `{:b}`. */ +export const i16Binary = (a: i16, f: Formatter): FmtResult => radix(a & 0xffff, f, 2, "0b"); +/** `i16`'s `Octal`, `{:o}`. */ +export const i16Octal = (a: i16, f: Formatter): FmtResult => radix(a & 0xffff, f, 8, "0o"); +/** `i16`'s `LowerExp`, `{:e}`. */ +export const i16LowerExp = (a: i16, f: Formatter): FmtResult => exp(a >= 0, String(Math.abs(a)), f, "e"); +/** `i16`'s `UpperExp`, `{:E}`. */ +export const i16UpperExp = (a: i16, f: Formatter): FmtResult => exp(a >= 0, String(Math.abs(a)), f, "E"); /** `i16`'s `Step`, which ranges step by: `n` moved by `by`, and whether that overflowed. */ export const i16Step: Step = (n, by) => narrowStep(n, by, -0x8000, 0x7fff, wrapI16); @@ -465,6 +556,16 @@ export const i32TryFrom = (value: number | Limbs): Result export const i32LowerHex = (a: i32, f: Formatter): FmtResult => hex(a >>> 0, f, false); /** `i32`'s `UpperHex`, `{:X}`. */ export const i32UpperHex = (a: i32, f: Formatter): FmtResult => hex(a >>> 0, f, true); +/** `i32`'s `Debug`, `Display` unless `{:x?}` or `{:X?}` makes it hex. */ +export const i32Debug = (a: i32, f: Formatter): FmtResult => debug(a, a >>> 0, f); +/** `i32`'s `Binary`, `{:b}`. */ +export const i32Binary = (a: i32, f: Formatter): FmtResult => radix(a >>> 0, f, 2, "0b"); +/** `i32`'s `Octal`, `{:o}`. */ +export const i32Octal = (a: i32, f: Formatter): FmtResult => radix(a >>> 0, f, 8, "0o"); +/** `i32`'s `LowerExp`, `{:e}`. */ +export const i32LowerExp = (a: i32, f: Formatter): FmtResult => exp(a >= 0, String(Math.abs(a)), f, "e"); +/** `i32`'s `UpperExp`, `{:E}`. */ +export const i32UpperExp = (a: i32, f: Formatter): FmtResult => exp(a >= 0, String(Math.abs(a)), f, "E"); /** `i32`'s `Step`, which ranges step by: `n` moved by `by`, and whether that overflowed. */ export const i32Step: Step = (n, by) => narrowStep(n, by, -0x80000000, 0x7fffffff, wrapI32); @@ -521,6 +622,16 @@ export const usizeTryFrom: (value: number | Limbs) => Result FmtResult = u32LowerHex as never; /** `usize`'s `UpperHex`, `{:X}`. */ export const usizeUpperHex: (a: usize, f: Formatter) => FmtResult = u32UpperHex as never; +/** `usize`'s `Debug`, `Display` unless `{:x?}` or `{:X?}` makes it hex. */ +export const usizeDebug: (a: usize, f: Formatter) => FmtResult = u32Debug as never; +/** `usize`'s `Binary`, `{:b}`. */ +export const usizeBinary: (a: usize, f: Formatter) => FmtResult = u32Binary as never; +/** `usize`'s `Octal`, `{:o}`. */ +export const usizeOctal: (a: usize, f: Formatter) => FmtResult = u32Octal as never; +/** `usize`'s `LowerExp`, `{:e}`. */ +export const usizeLowerExp: (a: usize, f: Formatter) => FmtResult = u32LowerExp as never; +/** `usize`'s `UpperExp`, `{:E}`. */ +export const usizeUpperExp: (a: usize, f: Formatter) => FmtResult = u32UpperExp as never; /** `usize`'s `Step`, which ranges step by: `n` moved by `by`, and whether that overflowed. */ export const usizeStep: Step = u32Step as never; /** `isize`'s `a + b`, panicking on overflow. */ @@ -567,6 +678,16 @@ export const isizeTryFrom: (value: number | Limbs) => Result FmtResult = i32LowerHex as never; /** `isize`'s `UpperHex`, `{:X}`. */ export const isizeUpperHex: (a: isize, f: Formatter) => FmtResult = i32UpperHex as never; +/** `isize`'s `Debug`, `Display` unless `{:x?}` or `{:X?}` makes it hex. */ +export const isizeDebug: (a: isize, f: Formatter) => FmtResult = i32Debug as never; +/** `isize`'s `Binary`, `{:b}`. */ +export const isizeBinary: (a: isize, f: Formatter) => FmtResult = i32Binary as never; +/** `isize`'s `Octal`, `{:o}`. */ +export const isizeOctal: (a: isize, f: Formatter) => FmtResult = i32Octal as never; +/** `isize`'s `LowerExp`, `{:e}`. */ +export const isizeLowerExp: (a: isize, f: Formatter) => FmtResult = i32LowerExp as never; +/** `isize`'s `UpperExp`, `{:E}`. */ +export const isizeUpperExp: (a: isize, f: Formatter) => FmtResult = i32UpperExp as never; /** `isize`'s `Step`, which ranges step by: `n` moved by `by`, and whether that overflowed. */ export const isizeStep: Step = i32Step as never; @@ -1044,8 +1165,23 @@ function wideDisplay(a: Wide, f: Formatter): FmtResult { return fmtPadIntegral(f, v >= 0n, "", (v < 0n ? -v : v).toString()); } +function wideDebug(a: Wide, bits: number, signed: boolean, f: Formatter): FmtResult { + const hexDigits = f.spec.debugHex; + return hexDigits === undefined ? wideDisplay(a, f) : wideHex(a, bits, signed, f, hexDigits === "X"); +} + +/** A value's bits as unsigned. */ +function wideBits(a: Wide, bits: number, signed: boolean): bigint { + return BigInt.asUintN(bits, exact(limbs(a, bits, signed))); +} + function wideHex(a: Wide, bits: number, signed: boolean, f: Formatter, upper: boolean): FmtResult { - return hex(BigInt.asUintN(bits, exact(limbs(a, bits, signed))), f, upper); + return hex(wideBits(a, bits, signed), f, upper); +} + +function wideExp(a: Wide, f: Formatter, letter: "e" | "E"): FmtResult { + const v = typeof a === "number" ? BigInt(a) : exact(a); + return exp(v >= 0n, (v < 0n ? -v : v).toString(), f, letter); } /** A value from a safe integer, or from a bigint of any size, wrapped into range. */ @@ -1142,6 +1278,16 @@ export const u64Display = (a: u64, f: Formatter): FmtResult => wideDisplay(a, f) export const u64LowerHex = (a: u64, f: Formatter): FmtResult => wideHex(a, 64, false, f, false); /** `u64`'s `UpperHex`, `{:X}`. */ export const u64UpperHex = (a: u64, f: Formatter): FmtResult => wideHex(a, 64, false, f, true); +/** `u64`'s `Debug`, `Display` unless `{:x?}` or `{:X?}` makes it hex. */ +export const u64Debug = (a: u64, f: Formatter): FmtResult => wideDebug(a, 64, false, f); +/** `u64`'s `Binary`, `{:b}`. */ +export const u64Binary = (a: u64, f: Formatter): FmtResult => radix(wideBits(a, 64, false), f, 2, "0b"); +/** `u64`'s `Octal`, `{:o}`. */ +export const u64Octal = (a: u64, f: Formatter): FmtResult => radix(wideBits(a, 64, false), f, 8, "0o"); +/** `u64`'s `LowerExp`, `{:e}`. */ +export const u64LowerExp = (a: u64, f: Formatter): FmtResult => wideExp(a, f, "e"); +/** `u64`'s `UpperExp`, `{:E}`. */ +export const u64UpperExp = (a: u64, f: Formatter): FmtResult => wideExp(a, f, "E"); /** A `u64` from a safe integer, or from a bigint of any size, wrapped into range. */ export const u64Of = (value: number | bigint): u64 => of(value, 64, false) as u64; /** `value as u64`. */ @@ -1232,6 +1378,16 @@ export const i64Display = (a: i64, f: Formatter): FmtResult => wideDisplay(a, f) export const i64LowerHex = (a: i64, f: Formatter): FmtResult => wideHex(a, 64, true, f, false); /** `i64`'s `UpperHex`, `{:X}`. */ export const i64UpperHex = (a: i64, f: Formatter): FmtResult => wideHex(a, 64, true, f, true); +/** `i64`'s `Debug`, `Display` unless `{:x?}` or `{:X?}` makes it hex. */ +export const i64Debug = (a: i64, f: Formatter): FmtResult => wideDebug(a, 64, true, f); +/** `i64`'s `Binary`, `{:b}`. */ +export const i64Binary = (a: i64, f: Formatter): FmtResult => radix(wideBits(a, 64, true), f, 2, "0b"); +/** `i64`'s `Octal`, `{:o}`. */ +export const i64Octal = (a: i64, f: Formatter): FmtResult => radix(wideBits(a, 64, true), f, 8, "0o"); +/** `i64`'s `LowerExp`, `{:e}`. */ +export const i64LowerExp = (a: i64, f: Formatter): FmtResult => wideExp(a, f, "e"); +/** `i64`'s `UpperExp`, `{:E}`. */ +export const i64UpperExp = (a: i64, f: Formatter): FmtResult => wideExp(a, f, "E"); /** A `i64` from a safe integer, or from a bigint of any size, wrapped into range. */ export const i64Of = (value: number | bigint): i64 => of(value, 64, true) as i64; /** `value as i64`. */ @@ -1318,6 +1474,16 @@ export const u128Display = (a: u128, f: Formatter): FmtResult => wideDisplay(a, export const u128LowerHex = (a: u128, f: Formatter): FmtResult => wideHex(a, 128, false, f, false); /** `u128`'s `UpperHex`, `{:X}`. */ export const u128UpperHex = (a: u128, f: Formatter): FmtResult => wideHex(a, 128, false, f, true); +/** `u128`'s `Debug`, `Display` unless `{:x?}` or `{:X?}` makes it hex. */ +export const u128Debug = (a: u128, f: Formatter): FmtResult => wideDebug(a, 128, false, f); +/** `u128`'s `Binary`, `{:b}`. */ +export const u128Binary = (a: u128, f: Formatter): FmtResult => radix(wideBits(a, 128, false), f, 2, "0b"); +/** `u128`'s `Octal`, `{:o}`. */ +export const u128Octal = (a: u128, f: Formatter): FmtResult => radix(wideBits(a, 128, false), f, 8, "0o"); +/** `u128`'s `LowerExp`, `{:e}`. */ +export const u128LowerExp = (a: u128, f: Formatter): FmtResult => wideExp(a, f, "e"); +/** `u128`'s `UpperExp`, `{:E}`. */ +export const u128UpperExp = (a: u128, f: Formatter): FmtResult => wideExp(a, f, "E"); /** A `u128` from a safe integer, or from a bigint of any size, wrapped into range. */ export const u128Of = (value: number | bigint): u128 => of(value, 128, false) as u128; /** `value as u128`. */ @@ -1406,6 +1572,16 @@ export const i128Display = (a: i128, f: Formatter): FmtResult => wideDisplay(a, export const i128LowerHex = (a: i128, f: Formatter): FmtResult => wideHex(a, 128, true, f, false); /** `i128`'s `UpperHex`, `{:X}`. */ export const i128UpperHex = (a: i128, f: Formatter): FmtResult => wideHex(a, 128, true, f, true); +/** `i128`'s `Debug`, `Display` unless `{:x?}` or `{:X?}` makes it hex. */ +export const i128Debug = (a: i128, f: Formatter): FmtResult => wideDebug(a, 128, true, f); +/** `i128`'s `Binary`, `{:b}`. */ +export const i128Binary = (a: i128, f: Formatter): FmtResult => radix(wideBits(a, 128, true), f, 2, "0b"); +/** `i128`'s `Octal`, `{:o}`. */ +export const i128Octal = (a: i128, f: Formatter): FmtResult => radix(wideBits(a, 128, true), f, 8, "0o"); +/** `i128`'s `LowerExp`, `{:e}`. */ +export const i128LowerExp = (a: i128, f: Formatter): FmtResult => wideExp(a, f, "e"); +/** `i128`'s `UpperExp`, `{:E}`. */ +export const i128UpperExp = (a: i128, f: Formatter): FmtResult => wideExp(a, f, "E"); /** A `i128` from a safe integer, or from a bigint of any size, wrapped into range. */ export const i128Of = (value: number | bigint): i128 => of(value, 128, true) as i128; /** `value as i128`. */ diff --git a/ts/runtime/rt/time.ts b/ts/runtime/rt/time.ts index 22d7876ae..bad66785f 100644 --- a/ts/runtime/rt/time.ts +++ b/ts/runtime/rt/time.ts @@ -219,26 +219,39 @@ export function durationHash(d: Duration, s: Hasher): void { /** `Debug`, as std writes it: `1.5s`, `20ms`, `3µs`, or `0ns`, padded to the width. */ export function durationDebug(d: Duration, f: Formatter): FmtResult { - let whole: u64; - let fraction: number; - let divisor: number; - let unit: string; - if (d.secs !== 0) { - [whole, fraction, divisor, unit] = [d.secs, d.nanos, NANOS_PER_SEC / 10, "s"]; - } else if (d.nanos >= 1_000_000) { - [whole, fraction, divisor, unit] = [Math.floor(d.nanos / 1_000_000), d.nanos % 1_000_000, 100_000, "ms"]; - } else if (d.nanos >= 1000) { - [whole, fraction, divisor, unit] = [Math.floor(d.nanos / 1000), d.nanos % 1000, 100, "µs"]; - } else { - [whole, fraction, divisor, unit] = [d.nanos as u64, 0, 1, "ns"]; - } - // The fraction's digits up to its last nonzero one; no precision is ever given. + const prefix = f.spec.plus ? "+" : ""; + if (d.secs !== 0) return decimal(f, d.secs, d.nanos, NANOS_PER_SEC / 10, prefix, "s"); + if (d.nanos >= 1_000_000) return decimal(f, Math.floor(d.nanos / 1_000_000), d.nanos % 1_000_000, 100_000, prefix, "ms"); + if (d.nanos >= 1000) return decimal(f, Math.floor(d.nanos / 1000), d.nanos % 1000, 100, prefix, "µs"); + return decimal(f, d.nanos as u64, 0, 1, prefix, "ns"); +} + +/** + * std's `fmt_decimal`: `whole`, then the digits of `fraction` from `divisor` down, rounded + * half to even to the precision or else up to the last nonzero one. + */ +function decimal(f: Formatter, whole: u64, fraction: number, divisor: number, prefix: string, unit: string): FmtResult { + const precision = f.spec.precision; let digits = ""; - while (fraction > 0) { + while (fraction > 0 && digits.length < (precision ?? 9)) { digits += Math.floor(fraction / divisor); fraction %= divisor; divisor /= 10; } - const text = typeof whole === "number" ? String(whole) : ((BigInt(whole.hi) << 32n) | BigInt(whole.lo)).toString(); - return fmtPad(f, text + (digits === "" ? "" : `.${digits}`) + unit); + let carry = false; + if (fraction > 0 && fraction >= divisor * 5) { + const last = digits.length > 0 ? Number(digits[digits.length - 1]) : typeof whole === "number" ? whole : whole.lo; + if (fraction > divisor * 5 || last % 2 === 1) { + const nines = /9*$/.exec(digits)![0].length; + const at = digits.length - nines - 1; + carry = at < 0; + digits = (carry ? "" : digits.slice(0, at) + (Number(digits[at]) + 1)) + "0".repeat(nines); + } + } + const big = typeof whole === "number" ? BigInt(whole) : (BigInt(whole.hi) << 32n) | BigInt(whole.lo); + const int = carry ? String(big + 1n) : String(big); + const point = Math.min(precision ?? digits.length, 9) > 0 ? `.${digits.padEnd(precision ?? digits.length, "0")}` : ""; + // A width pads the whole text, which the precision has already cut. + const uncut = precision === undefined ? f : { out: f.out, spec: { ...f.spec, precision: undefined } }; + return fmtPad(uncut, `${prefix}${int}${point}${unit}`); } diff --git a/ts/src/lower/fmt.rs b/ts/src/lower/fmt.rs index cd6b3a1f1..d116dabab 100644 --- a/ts/src/lower/fmt.rs +++ b/ts/src/lower/fmt.rs @@ -21,6 +21,10 @@ pub enum Trait { Debug, LowerHex, UpperHex, + Octal, + Binary, + LowerExp, + UpperExp, } impl Trait { @@ -36,6 +40,10 @@ impl Trait { ["fmt", "Debug"] => Some(Self::Debug), ["fmt", "LowerHex"] => Some(Self::LowerHex), ["fmt", "UpperHex"] => Some(Self::UpperHex), + ["fmt", "Octal"] => Some(Self::Octal), + ["fmt", "Binary"] => Some(Self::Binary), + ["fmt", "LowerExp"] => Some(Self::LowerExp), + ["fmt", "UpperExp"] => Some(Self::UpperExp), _ => None, } } @@ -46,6 +54,10 @@ impl Trait { Self::Debug => "Debug", Self::LowerHex => "LowerHex", Self::UpperHex => "UpperHex", + Self::Octal => "Octal", + Self::Binary => "Binary", + Self::LowerExp => "LowerExp", + Self::UpperExp => "UpperExp", } } @@ -65,26 +77,25 @@ impl Trait { } } -/// The trait a `format_args!` argument's constructor, `Argument::new_display` and the -/// like, writes its value by, or the construct outside the subset that it is. -pub fn argument(name: &str) -> Result { - match name { - "new_display" => Ok(Trait::Display), - "new_debug" => Ok(Trait::Debug), - "new_lower_hex" => Ok(Trait::LowerHex), - "new_upper_hex" => Ok(Trait::UpperHex), - "from_usize" => Err(FROM_ARGUMENT), - "new_octal" => Err("`Octal` formatting, as in `{:o}`,"), - "new_binary" => Err("`Binary` formatting, as in `{:b}`,"), - "new_lower_exp" => Err("`LowerExp` formatting, as in `{:e}`,"), - "new_upper_exp" => Err("`UpperExp` formatting, as in `{:E}`,"), - "new_pointer" => Err("`Pointer` formatting, as in `{:p}`,"), - _ => Err("an unexpected `format_args!` lowering"), - } +/// What a `format_args!` argument's constructor, `Argument::new_display` and the like, +/// makes: a value written by a trait, or `None` for a width or precision, as in `{:1$}`. +/// Otherwise, the construct outside the subset that it is. +pub fn argument(name: &str) -> Result, &'static str> { + Ok(Some(match name { + "new_display" => Trait::Display, + "new_debug" => Trait::Debug, + "new_lower_hex" => Trait::LowerHex, + "new_upper_hex" => Trait::UpperHex, + "new_octal" => Trait::Octal, + "new_binary" => Trait::Binary, + "new_lower_exp" => Trait::LowerExp, + "new_upper_exp" => Trait::UpperExp, + "from_usize" => return Ok(None), + "new_pointer" => return Err("`Pointer` formatting, as in `{:p}`,"), + _ => return Err("an unexpected `format_args!` lowering"), + })) } -const FROM_ARGUMENT: &str = "a width or precision from an argument, as in `{:1$}`,"; - /// A formatter's type, for the parameters of the functions written here. fn formatter() -> Type { Type::Rt("Formatter", Vec::new()) @@ -222,9 +233,14 @@ pub fn std_impl<'tcx>( } ty::Int(_) | ty::Uint(_) => { let method = match tr { - Trait::Display | Trait::Debug => "display", + Trait::Display => "display", + Trait::Debug => "debug", Trait::LowerHex => "lowerHex", Trait::UpperHex => "upperHex", + Trait::Octal => "octal", + Trait::Binary => "binary", + Trait::LowerExp => "lowerExp", + Trait::UpperExp => "upperExp", }; Int::of(ty)?.method(method, vec![value, f]) } @@ -300,14 +316,28 @@ pub enum Piece { pub struct Spec { fill: char, align: Option, + plus: bool, alternate: bool, zero: bool, - width: Option, + debug_hex: Option, + width: Option, + precision: Option, +} + +/// A width or precision: in the template, or the `index`th argument's. +#[derive(Clone, Copy)] +pub enum Count { + Is(u16), + Arg(usize), } impl Spec { - /// The runtime's `Spec` object, or `None` for the defaults. - pub fn object(&self) -> Option { + /// The runtime's `Spec` object, or `None` for the defaults. `arg` reads an argument. + pub fn object(&self, arg: impl Fn(usize) -> Expr) -> Option { + let count = |count: Count| match count { + Count::Is(n) => Expr::lit(n.to_string()), + Count::Arg(index) => Expr::rt("fmtCountOf", vec![arg(index)]), + }; let mut props = Vec::new(); if self.fill != ' ' { props.push(("fill", Expr::Str(self.fill.to_string()))); @@ -315,14 +345,23 @@ impl Spec { if let Some(align) = self.align { props.push(("align", Expr::Str(align.to_string()))); } + if self.plus { + props.push(("plus", Expr::lit("true"))); + } if self.alternate { props.push(("alternate", Expr::lit("true"))); } if self.zero { props.push(("zero", Expr::lit("true"))); } + if let Some(hex) = self.debug_hex { + props.push(("debugHex", Expr::Str(hex.to_string()))); + } if let Some(width) = self.width { - props.push(("width", Expr::lit(width.to_string()))); + props.push(("width", count(width))); + } + if let Some(precision) = self.precision { + props.push(("precision", count(precision))); } let props: Vec<(Key, Expr)> = props.into_iter().map(|(k, v)| (Key::Name(k.into()), v)).collect(); (!props.is_empty()).then_some(Expr::Object(props)) @@ -331,17 +370,17 @@ impl Spec { // `FormattingOptions`' flags, as `core::fmt` lays them out. const SIGN_PLUS: u32 = 1 << 21; -const SIGN_MINUS: u32 = 1 << 22; const ALTERNATE: u32 = 1 << 23; const ZERO_PAD: u32 = 1 << 24; -const DEBUG_HEX: u32 = 0b11 << 25; +const DEBUG_LOWER_HEX: u32 = 1 << 25; +const DEBUG_UPPER_HEX: u32 = 1 << 26; const WIDTH: u32 = 1 << 27; const PRECISION: u32 = 1 << 28; const FILL: u32 = (1 << 21) - 1; const DEFAULT_FLAGS: u32 = ' ' as u32 | 3 << 29; /// Decode a template as `core::fmt::write` reads it: literal pieces, and placeholders -/// with their argument and options. An option outside the subset is an error naming it. +/// with their argument and options. The `-` flag is dropped, as std's impls ignore it. pub fn decode(template: &[u8]) -> Result, &'static str> { const TRUNCATED: &str = "a truncated template"; let byte = |i: usize| template.get(i).copied().ok_or(TRUNCATED); @@ -370,6 +409,7 @@ pub fn decode(template: &[u8]) -> Result, &'static str> { 0xc0..=0xff => { let mut flags = DEFAULT_FLAGS; let mut width = 0; + let mut precision = 0; if n & 1 != 0 { flags = u32::from_le_bytes([byte(i)?, byte(i + 1)?, byte(i + 2)?, byte(i + 3)?]); i += 4; @@ -379,27 +419,20 @@ pub fn decode(template: &[u8]) -> Result, &'static str> { i += 2; } if n & 4 != 0 { + precision = u16_at(i)?; i += 2; } if n & 8 != 0 { next = usize::from(u16_at(i)?); i += 2; } - if n & (16 | 32) != 0 { - return Err(FROM_ARGUMENT); - } - if flags & PRECISION != 0 { - return Err("a precision, as in `{:.2}`,"); - } - if flags & SIGN_PLUS != 0 { - return Err("the `+` flag of a format spec"); - } - if flags & SIGN_MINUS != 0 { - return Err("the `-` flag of a format spec"); - } - if flags & DEBUG_HEX != 0 { - return Err("hex `Debug`, as in `{:x?}`,"); - } + // An indirect count is the index of the argument that holds it. + let count = |set: u32, indirect: u8, value: u16| { + (flags & set != 0).then_some(match n & indirect != 0 { + true => Count::Arg(value.into()), + false => Count::Is(value), + }) + }; let spec = Spec { fill: char::from_u32(flags & FILL).ok_or("a fill that is not a char")?, align: match flags >> 29 & 3 { @@ -408,9 +441,16 @@ pub fn decode(template: &[u8]) -> Result, &'static str> { 2 => Some('^'), _ => None, }, + plus: flags & SIGN_PLUS != 0, alternate: flags & ALTERNATE != 0, zero: flags & ZERO_PAD != 0, - width: (flags & WIDTH != 0).then_some(width), + debug_hex: match flags { + f if f & DEBUG_LOWER_HEX != 0 => Some('x'), + f if f & DEBUG_UPPER_HEX != 0 => Some('X'), + _ => None, + }, + width: count(WIDTH, 16, width), + precision: count(PRECISION, 32, precision), }; pieces.push(Piece::Arg { index: next, spec }); next += 1; diff --git a/ts/src/lower/library.rs b/ts/src/lower/library.rs index f8da3d846..2aa198649 100644 --- a/ts/src/lower/library.rs +++ b/ts/src/lower/library.rs @@ -1026,7 +1026,7 @@ fn mapping<'tcx>( None => Expr::rt("fmtFormat", vec![parts]), } } - ("Display" | "Debug" | "LowerHex" | "UpperHex", "fmt") => { + ("Display" | "Debug" | "LowerHex" | "UpperHex" | "Octal" | "Binary" | "LowerExp" | "UpperExp", "fmt") => { let tr = fmt::Trait::of(tcx, tcx.trait_of_assoc(call.def_id)?)?; let [value, f] = <[Expr; 2]>::try_from(args).ok()?; fmt::std_impl(b, tr, targ(gargs, 0), value, f, span, out)? diff --git a/ts/src/lower/mir/call.rs b/ts/src/lower/mir/call.rs index a2d742383..9ddfa2063 100644 --- a/ts/src/lower/mir/call.rs +++ b/ts/src/lower/mir/call.rs @@ -523,7 +523,12 @@ impl<'m, 'b, 'a, 'tcx> Fx<'m, 'b, 'a, 'tcx> { // and a template of literal pieces and placeholders. ("Argument", name) if name.starts_with("new_") || name == "from_usize" => { let tr = match fmt::argument(name) { - Ok(tr) => tr, + Ok(Some(tr)) => tr, + // A width or precision, which the template's spec reads. + Ok(None) => { + let count = self.operand(&args[0].node, span, out); + return done(Expr::rt("fmtCount", vec![count]), true); + } Err(construct) => { self.err(span, format!("{construct} is not supported")); return done(Expr::undefined(), false); @@ -579,11 +584,12 @@ impl<'m, 'b, 'a, 'tcx> Fx<'m, 'b, 'a, 'tcx> { match piece { Piece::Lit(s) => parts.push(Expr::Str(s)), Piece::Arg { index, spec } => { - let value = match made.as_ref().and_then(|p| p.get(index)) { + let arg = |index: usize| match made.as_ref().and_then(|p| p.get(index)) { Some(part) => part.clone(), None => values.clone().index(Expr::lit(index.to_string())), }; - parts.push(match spec.object() { + let value = arg(index); + parts.push(match spec.object(arg) { Some(spec) => Expr::rt("fmtSpec", vec![spec, value]), None => value, });