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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion quest/m3/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,5 @@ generic std gap is planned here even when moq never calls it.
- [Binding gaps](/quest/m3/ts-bind-gaps.md) - bound types as keys, unit returns checked, renamed dependencies
- [Drop order in std's folds and iterators](/quest/m3/ts-drop-order.md) - the values that drop still refused in std's folds, zips, flattens, and collects drop as std's do
- [Ordering in std](/quest/m3/ts-ordering.md) - `cmp::max`/`min`, `is_sorted`, and `BinaryHeap`, and #173's cost on integers measured
- [Debug and Display of Arc and ranges](/quest/m3/ts-fmt-wrappers.md) - `Arc<T>` formats as `T`, and ranges as std's `Debug`
- [Into targets through a chain of From implementations](/quest/m3/ffi-from-chains.md) - `sources` follows more than one level, once a consumer's parameter needs it
- [Port the workflow guard to kixelated/quest](/quest/m3/quest-workflow-guard.md) - quest's environment guard parses YAML as this repository's does
16 changes: 0 additions & 16 deletions quest/m3/ts-fmt-wrappers.md

This file was deleted.

19 changes: 19 additions & 0 deletions ts/fixtures/lang/expected/fmt.Clip.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Generated by rust2-ts. Do not edit.

import * as rt from "./rt.ts";

/** `Debug` that pads its text, so a width and precision passed to it show, and marks `#`. */
export interface Clip {
_0: string;
}

export function fmt$Debug(self: Clip, f: rt.Formatter): rt.Result<undefined, rt.FmtError> {
if (rt.fmtAlternate(f)) {
if (!rt.fmtWriteStr(f, "#").ok) {
return rt.Err(new rt.FmtError());
}
}
return rt.fmtPad(f, self._0);
}

//# sourceMappingURL=fmt.Clip.ts.map
33 changes: 33 additions & 0 deletions ts/fixtures/lang/expected/fmt.Shared.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Generated by rust2-ts. Do not edit.

import * as rt from "./rt.ts";
import * as Pair from "./fmt.Pair.ts";

export function fmt$Debug(self: Shared, f: rt.Formatter): rt.Result<undefined, rt.FmtError> {
const _3: string = "Shared";
const _4: string = "arc";
const _5: rt.Fmt = (f: rt.Formatter) => Pair.fmt$Debug(self.arc.value, f);
const _7: string = "span";
const _8: rt.Fmt = (f: rt.Formatter) => rt.fmtRange(self.span, f, rt.u16Debug);
const _10: string = "upto";
const _11: rt.Fmt = (f: rt.Formatter) => rt.fmtRangeToInclusive(self.upto, f, rt.u8Debug);
return rt.debugStructFinish(rt.debugStructField(rt.debugStructField(rt.debugStructField(rt.fmtDebugStruct(f, _3), _4, _5), _7, _8), _10, _11));
}

export class Shared {
arc: rt.Arc<Pair.Pair>;
span: rt.Range<rt.u16>;
upto: { end: rt.u8; inclusive: true };

constructor(arc: rt.Arc<Pair.Pair>, span: rt.Range<rt.u16>, upto: { end: rt.u8; inclusive: true }) {
this.arc = arc;
this.span = span;
this.upto = upto;
}

[Symbol.dispose](): void {
this.arc[Symbol.dispose]();
}
}

//# sourceMappingURL=fmt.Shared.ts.map
117 changes: 116 additions & 1 deletion ts/fixtures/lang/expected/fmt.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// Generated by rust2-ts. Do not edit.

import * as rt from "./rt.ts";
import { copy$Pair } from "./lib.ts";
import { copy$Clip, copy$Pair } from "./lib.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 Clip from "./fmt.Clip.ts";
import * as Fails from "./fmt.Fails.ts";
import * as Hex from "./fmt.Hex.ts";
import * as Kind from "./fmt.Kind.ts";
Expand All @@ -14,6 +15,7 @@ import * as Noted from "./fmt.Noted.ts";
import * as Padded from "./fmt.Padded.ts";
import * as Pair from "./fmt.Pair.ts";
import * as Seq from "./fmt.Seq.ts";
import * as Shared from "./fmt.Shared.ts";
import * as Six from "./fmt.Six.ts";
import * as Tup from "./fmt.Tup.ts";
import * as Unit from "./fmt.Unit.ts";
Expand Down Expand Up @@ -596,4 +598,117 @@ export function panics(kind: rt.u8, rest: rt.ByteSlice, out: rt.ByteVec): void {
}
}

/**
* std's ranges' `Debug`, which passes its options to each bound, and an `Arc`'s `Debug`
* and `Display`, which pass them to what it holds.
*/
export function wrapped(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.i32, rt.i32] = [rt.i32Sub(at(0) as rt.i32, 128), rt.i32Sub(at(1) as rt.i32, 100)];
const a: rt.i32 = _6[0];
const b: rt.i32 = _6[1];
const w: rt.usize = rt.u8Rem(at(2), 10) as rt.usize;
const _33: rt.Range<rt.i32> = new rt.Range(a, b);
const _35: rt.RangeInclusive<rt.i32> = new rt.RangeInclusive(a, b, rt.i32Step);
const _37: { start: rt.i32 } = { start: a };
const _39: { end: rt.i32 } = { end: b };
const _41: { end: rt.i32; inclusive: true } = { end: b, inclusive: true };
const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtRange(_33, f, rt.i32Debug), (f: rt.Formatter) => rt.fmtRangeInclusive(_35, f, rt.i32Debug), (f: rt.Formatter) => rt.fmtRangeFrom(_37, f, rt.i32Debug), (f: rt.Formatter) => rt.fmtRangeTo(_39, f, rt.i32Debug), (f: rt.Formatter) => rt.fmtRangeToInclusive(_41, f, rt.i32Debug), (f: rt.Formatter) => rt.fmtRangeFull(undefined, f)];
put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4], " ", args2[5]]));
const _60: rt.Range<rt.i32> = new rt.Range(a, b);
const _62: rt.RangeInclusive<rt.i32> = new rt.RangeInclusive(a, b, rt.i32Step);
const _64: { start: rt.i32 } = { start: a };
const _66: { end: rt.i32 } = { end: b };
const _68: { end: rt.i32; inclusive: true } = { end: b, inclusive: true };
const _70: rt.Range<rt.i32> = new rt.Range(a, b);
const _72: rt.RangeInclusive<rt.i32> = new rt.RangeInclusive(a, b, rt.i32Step);
const _74: { end: rt.i32; inclusive: true } = { end: b, inclusive: true };
const _75: undefined = undefined;
const _77: rt.Range<rt.i32> = new rt.Range(a, b);
const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtRange(_60, f, rt.i32Debug), (f: rt.Formatter) => rt.fmtRangeInclusive(_62, f, rt.i32Debug), (f: rt.Formatter) => rt.fmtRangeFrom(_64, f, rt.i32Debug), (f: rt.Formatter) => rt.fmtRangeTo(_66, f, rt.i32Debug), (f: rt.Formatter) => rt.fmtRangeToInclusive(_68, f, rt.i32Debug), (f: rt.Formatter) => rt.fmtRange(_70, f, rt.i32Debug), (f: rt.Formatter) => rt.fmtRangeInclusive(_72, f, rt.i32Debug), rt.fmtCount(w), (f: rt.Formatter) => rt.fmtRangeToInclusive(_74, f, rt.i32Debug), (f: rt.Formatter) => rt.fmtRangeFull(_75, f), (f: rt.Formatter) => rt.fmtRange(_77, f, rt.i32Debug)];
put(out, rt.fmtFormat([rt.fmtSpec({ width: 5 }, args4[0]), "|", rt.fmtSpec({ align: "<", width: 4 }, args4[1]), "|", rt.fmtSpec({ plus: true }, args4[2]), "|", rt.fmtSpec({ zero: true, width: 5 }, args4[3]), "|", rt.fmtSpec({ debugHex: "x" }, args4[4]), "|", rt.fmtSpec({ alternate: true, debugHex: "X" }, args4[5]), "|", rt.fmtSpec({ width: rt.fmtCountOf(args4[7]) }, args4[6]), "|", rt.fmtSpec({ align: "^", width: rt.fmtCountOf(args4[7]) }, args4[8]), "|", rt.fmtSpec({ align: ">", width: 3 }, args4[9]), "|", rt.fmtSpec({ alternate: true }, args4[10])]));
const _96: 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 (!(_96 < 14)) {
rt.panic("index out of bounds: the len is " + 14 + " but the index is " + _96);
}
const lo: Clip.Clip = { _0: ["", "a", "héllo", "日本語", "tab\tnew\nline\r", "quote\"back\\slash'", "\u0000\u0001\u001f", "€Ÿ ­", "é", "‍ᅟ\u2028 ", "͸􏿽𽀀𿱀", "😀 🇦", "゙゚ン", "{}"][_96] };
const _109: rt.usize = rt.usizeRem(at(4) as rt.usize, ["", "a", "héllo", "日本語", "tab\tnew\nline\r", "quote\"back\\slash'", "\u0000\u0001\u001f", "€Ÿ ­", "é", "‍ᅟ\u2028 ", "͸􏿽𽀀𿱀", "😀 🇦", "゙゚ン", "{}"].length);
if (!(_109 < 14)) {
rt.panic("index out of bounds: the len is " + 14 + " but the index is " + _109);
}
const hi: Clip.Clip = { _0: ["", "a", "héllo", "日本語", "tab\tnew\nline\r", "quote\"back\\slash'", "\u0000\u0001\u001f", "€Ÿ ­", "é", "‍ᅟ\u2028 ", "͸􏿽𽀀𿱀", "😀 🇦", "゙゚ン", "{}"][_109] };
const _127: rt.Range<Clip.Clip> = new rt.Range(lo, hi);
const _129: rt.RangeInclusive<Clip.Clip> = new rt.RangeInclusive(copy$Clip(lo), copy$Clip(hi));
const _131: { end: Clip.Clip } = { end: hi };
const _133: { start: Clip.Clip } = { start: lo };
const _135: { end: Clip.Clip; inclusive: true } = { end: lo, inclusive: true };
const args6: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtRange(_127, f, (value: Clip.Clip, f: rt.Formatter) => Clip.fmt$Debug(value, f)), (f: rt.Formatter) => rt.fmtRangeInclusive(_129, f, (value: Clip.Clip, f: rt.Formatter) => Clip.fmt$Debug(value, f)), (f: rt.Formatter) => rt.fmtRangeTo(_131, f, (value: Clip.Clip, f: rt.Formatter) => Clip.fmt$Debug(value, f)), (f: rt.Formatter) => rt.fmtRangeFrom(_133, f, (value: Clip.Clip, f: rt.Formatter) => Clip.fmt$Debug(value, f)), rt.fmtCount(w), (f: rt.Formatter) => rt.fmtRangeToInclusive(_135, f, (value: Clip.Clip, f: rt.Formatter) => Clip.fmt$Debug(value, f))];
put(out, rt.fmtFormat([args6[0], "|", rt.fmtSpec({ width: 8, precision: 2 }, args6[1]), "|", rt.fmtSpec({ alternate: true }, args6[2]), "|", rt.fmtSpec({ fill: "_", align: ">", width: rt.fmtCountOf(args6[4]), precision: 1 }, args6[3]), "|", rt.fmtSpec({ alternate: true, width: 4 }, args6[5])]));
const _148: [rt.u32, rt.u32] = [rt.u32Mul(at(5) as rt.u32, 257), at(6) as rt.u32];
const x: rt.u32 = _148[0];
const y: rt.u32 = _148[1];
const _167: rt.Range<Hex.Hex> = new rt.Range({ _0: x }, { _0: y });
const _171: rt.RangeInclusive<Hex.Hex> = new rt.RangeInclusive({ _0: x }, { _0: y });
const _175: { end: Hex.Hex } = { end: { _0: y } };
const args8: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtRange(_167, f, (value: Hex.Hex, f: rt.Formatter) => Hex.fmt$Debug(value, f)), (f: rt.Formatter) => rt.fmtRangeInclusive(_171, f, (value: Hex.Hex, f: rt.Formatter) => Hex.fmt$Debug(value, f)), (f: rt.Formatter) => rt.fmtRangeTo(_175, f, (value: Hex.Hex, f: rt.Formatter) => Hex.fmt$Debug(value, f))];
put(out, rt.fmtFormat([args8[0], "|", rt.fmtSpec({ align: ">", width: 9 }, args8[1]), "|", rt.fmtSpec({ alternate: true }, args8[2])]));
const part3 = new rt.Range({ _0: at(7), _1: -1 }, { _0: 1, _1: { hi: -0x80000000, lo: 0 } as rt.i64 });
const args10: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtRange(part3, f, (value: Pair.Pair, f: rt.Formatter) => Pair.fmt$Debug(value, f))];
put(out, rt.fmtFormat([args10[0], "|", rt.fmtSpec({ alternate: true }, args10[0]), "|", rt.fmtSpec({ debugHex: "x" }, args10[0]), "|", rt.fmtSpec({ plus: true }, args10[0])]));
const drained: rt.RangeInclusive<rt.u8> = new rt.RangeInclusive(rt.u8Rem(at(8), 4), rt.u8Rem(at(9), 4), rt.u8Step);
while (rt.iterToOption(drained.next()) !== undefined) {
}
const top: rt.RangeInclusive<rt.u8> = new rt.RangeInclusive(rt.max(at(8), 250), 255, rt.u8Step);
while (rt.iterToOption(top.next()) !== undefined) {
}
const back: rt.RangeInclusive<rt.u8> = new rt.RangeInclusive(0, rt.u8Rem(at(9), 3), rt.u8Step);
while (rt.iterToOption(back.nextBack()) !== undefined) {
}
const far: rt.RangeInclusive<rt.u8> = new rt.RangeInclusive(at(8), at(9), rt.u8Step);
const _244: rt.usize = rt.u8Rem(at(10), 8) as rt.usize;
rt.iterNth(far, _244);
const _257: rt.RangeInclusive<rt.i32> = new rt.RangeInclusive(0, 0, rt.i32Step);
const args12: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtRangeInclusive(drained, f, rt.u8Debug), (f: rt.Formatter) => rt.fmtRangeInclusive(top, f, rt.u8Debug), (f: rt.Formatter) => rt.fmtRangeInclusive(back, f, rt.u8Debug), (f: rt.Formatter) => rt.fmtRangeInclusive(far, f, rt.u8Debug), (f: rt.Formatter) => rt.fmtRangeInclusive(_257, f, rt.i32Debug)];
put(out, rt.fmtFormat([args12[0], " ", args12[1], " ", args12[2], " ", args12[3], " ", args12[4]]));
const arc: rt.Arc<Hex.Hex> = new rt.Arc({ _0: x });
const args14: rt.Fmt[] = [(f: rt.Formatter) => Hex.fmt$Display(arc.value, f), (f: rt.Formatter) => Hex.fmt$Debug(arc.value, f)];
put(out, rt.fmtFormat([args14[0], "|", rt.fmtSpec({ align: ">", width: 12 }, args14[0]), "|", rt.fmtSpec({ alternate: true }, args14[0]), "|", args14[1], "|", rt.fmtSpec({ align: ">", width: 6 }, args14[1]), "|", rt.fmtSpec({ alternate: true }, args14[1])]));
put(out, rt.fmtToString((f: rt.Formatter) => Hex.fmt$Display(arc.value, f)));
const nested_: rt.Arc<rt.Arc<rt.i32>> = new rt.Arc(new rt.Arc(a));
const args16: rt.Fmt[] = [(f: rt.Formatter) => rt.i32Display(nested_.value.value, f), (f: rt.Formatter) => rt.i32Debug(nested_.value.value, f), rt.fmtCount(w)];
put(out, rt.fmtFormat([args16[0], "|", rt.fmtSpec({ plus: true, zero: true, width: 5 }, args16[0]), "|", args16[1], "|", rt.fmtSpec({ debugHex: "x" }, args16[1]), "|", rt.fmtSpec({ alternate: true, debugHex: "X" }, args16[1]), "|", rt.fmtSpec({ align: "<", width: 6 }, args16[1]), "|", rt.fmtSpec({ align: "^", plus: true, width: rt.fmtCountOf(args16[2]) }, args16[0])]));
const _310: 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 (!(_310 < 14)) {
rt.panic("index out of bounds: the len is " + 14 + " but the index is " + _310);
}
const rc: rt.Arc<string> = new rt.Arc(["", "a", "héllo", "日本語", "tab\tnew\nline\r", "quote\"back\\slash'", "\u0000\u0001\u001f", "€Ÿ ­", "é", "‍ᅟ\u2028 ", "͸􏿽𽀀𿱀", "😀 🇦", "゙゚ン", "{}"][_310]);
const args18: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, rc.value), (f: rt.Formatter) => rt.fmtStr(rc.value, f)];
put(out, rt.fmtFormat([args18[0], "|", rt.fmtSpec({ align: ">", width: 8, precision: 2 }, args18[0]), "|", args18[1]]));
const list: rt.Arc<Pair.Pair[]> = new rt.Arc([{ _0: at(7), _1: 2 }, { _0: 3, _1: -4 }].map(copy$Pair));
const args20: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(list.value, f, (value: Pair.Pair, f: rt.Formatter) => Pair.fmt$Debug(value, f))];
put(out, rt.fmtFormat([args20[0], " ", rt.fmtSpec({ alternate: true }, args20[0])]));
const held: rt.Range<rt.Arc<rt.i32>> = new rt.Range(new rt.Arc(a), new rt.Arc(b));
const _366: rt.Range<rt.Arc<Clip.Clip>> = new rt.Range(new rt.Arc(copy$Clip(lo)), new rt.Arc(copy$Clip(hi)));
const args22: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtRange(held, f, (value: rt.Arc<rt.i32>, f: rt.Formatter) => rt.i32Debug(value.value, f)), (f: rt.Formatter) => rt.fmtRange(_366, f, (value: rt.Arc<Clip.Clip>, f: rt.Formatter) => Clip.fmt$Debug(value.value, f))];
put(out, rt.fmtFormat([args22[0], " ", rt.fmtSpec({ plus: true, zero: true, width: 4 }, args22[0]), " ", args22[1]]));
const shared: Shared.Shared = new Shared.Shared(new rt.Arc({ _0: at(7), _1: 5 }), new rt.Range(at(8) as rt.u16, 300), { end: at(9), inclusive: true });
const args24: rt.Fmt[] = [(f: rt.Formatter) => Shared.fmt$Debug(shared, f)];
put(out, rt.fmtFormat([args24[0], " ", rt.fmtSpec({ alternate: true }, args24[0])]));
const _405: 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 (!(_405 < 14)) {
rt.panic("index out of bounds: the len is " + 14 + " but the index is " + _405);
}
const t: rt.Arc<string> = new rt.Arc(["", "a", "héllo", "日本語", "tab\tnew\nline\r", "quote\"back\\slash'", "\u0000\u0001\u001f", "€Ÿ ­", "é", "‍ᅟ\u2028 ", "͸􏿽𽀀𿱀", "😀 🇦", "゙゚ン", "{}"][_405]);
const args26: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, t.value), (f: rt.Formatter) => rt.fmtStr(t.value, f)];
put(out, rt.fmtFormat([args26[0], " ", args26[1], " ", rt.fmtSpec({ align: ">", width: 9, precision: 2 }, args26[0])]));
t[Symbol.dispose]();
shared[Symbol.dispose]();
list[Symbol.dispose]();
rc[Symbol.dispose]();
nested_[Symbol.dispose]();
arc[Symbol.dispose]();
}

//# sourceMappingURL=fmt.ts.map
Loading