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 @@ -20,7 +20,6 @@ generic std gap is planned here even when moq never calls it.
- [Trait objects](/quest/m3/ts-dyn.md) - `dyn Trait` and `Box<dyn Future>` translate, so a consumer neither rewrites nor binds them
- [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
- [An inclusive range drained by a fold](/quest/m3/ts-range-fold.md) - a folded `RangeInclusive` ends in core's state
- [bool's combinators from core's MIR](/quest/m3/ts-bool-core.md) - `bool::then` lowers from core, retiring `rt.boolThen`
- [Binding gaps](/quest/m3/ts-bind-gaps.md) - bound types as keys, unit returns checked, renamed dependencies
Expand Down
15 changes: 0 additions & 15 deletions quest/m3/ts-partial-ord.md

This file was deleted.

4 changes: 4 additions & 0 deletions ts/MIGRATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

- `rt.ordMax`, `rt.ordMin`, and `rt.sliceSortByKey` take a `PartialOrd::lt` rather than a
`partial_cmp`, and `rt.ordClamp` takes `le`, `lt`, and `gt`; `rt.cmpLt` makes one from a
`partial_cmp`. `rt.sliceSortBy` takes only an `Ord::cmp`-like comparator: sort by an
`lt` with `rt.sliceSort`.
- A trait object in a function's suffix is named for its trait and the types it binds:
`show$dynstdfmtDebug` is `show$dyn_Debug`, and `poll$dyn_Future_u64` is a
`dyn Future<Output = u64>`'s.
Expand Down
2 changes: 1 addition & 1 deletion ts/fixtures/lang/expected/cows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export function cows(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void {
}
rt.byteVecPush(out, _189 ? 1 : 0);
}
rt.byteVecPush(out, rt.ordMax(a, b, rt.cmpStr) === b ? 1 : 0);
rt.byteVecPush(out, rt.ordMax(a, b, rt.cmpLt(rt.cmpStr)) === b ? 1 : 0);
} else if (_14 === 3) {
const n: Named.Named = Named.new(first, kind);
const m2: Named.Named = Named.clone$Clone(n);
Expand Down
6 changes: 3 additions & 3 deletions ts/fixtures/lang/expected/durations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ export function durations(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): voi
}
rt.byteVecPush(out, _144 ? 1 : 0);
}
putDuration(out, rt.ordMax(a, b, rt.durationCmp));
putDuration(out, rt.ordMin(a, b, rt.durationCmp));
putDuration(out, rt.ordMax(a, b, rt.cmpLt(rt.durationCmp)));
putDuration(out, rt.ordMin(a, b, rt.cmpLt(rt.durationCmp)));
const seen: rt.BTreeMap<rt.Duration, rt.u8> = rt.btreeNew(rt.durationCmp) as rt.BTreeMap<rt.Duration, rt.u8>;
const iter2: rt.Iter<[rt.usize, rt.Duration]> = rt.iterEnumerate(rt.iterSlice([a, b, { secs: 1, nanos: 500000000 }, a, { secs: 0, nanos: 0 }]));
while (true) {
Expand Down Expand Up @@ -176,7 +176,7 @@ export function durations(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): voi
w.start = rt.durationSub(w.start, b);
putDuration(out, w.start);
if (w.len !== undefined) {
const _283: rt.Duration = rt.ordMin(a, b, rt.durationCmp);
const _283: rt.Duration = rt.ordMin(a, b, rt.cmpLt(rt.durationCmp));
w.len = rt.durationSub(w.len, _283);
}
putOpt(out, w.len);
Expand Down
26 changes: 13 additions & 13 deletions ts/fixtures/lang/expected/edits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export function edits(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void {
rt.byteVecPush(out, names2.length & 0xff);
} else if (_8 === 2) {
const v3: rt.u16[] = words.slice();
rt.sliceSortBy(v3, rt.cmp);
rt.sliceSort(v3, rt.cmpLt(rt.cmp));
putU16s(out, v3);
const v4: rt.u16[] = words.slice();
rt.sliceSortBy(v4, (a: rt.u16, b4: rt.u16): rt.Ordering => {
Expand All @@ -114,15 +114,15 @@ export function edits(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void {
}));
rt.sliceSortByKey(pairs2, (p2: [rt.u16, rt.u16]): rt.u16 => {
return p2[0];
}, rt.cmp);
}, rt.cmpLt(rt.cmp));
for (const _159 of pairs2) {
putU16s(out, [_159[0], _159[1]]);
}
rt.sliceSortByKey(pairs2, (_213: [rt.u16, rt.u16]): [rt.u16, rt.u16, rt.u16] => {
const a2: rt.u16 = _213[0];
const b5: rt.u16 = _213[1];
return [rt.u16Rem(b5, 3), a2, b5] as [rt.u16, rt.u16, rt.u16];
}, rt.cmpTuple([rt.cmp, rt.cmp, rt.cmp]));
}, rt.cmpLt(rt.cmpTuple([rt.cmp, rt.cmp, rt.cmp])));
for (const _176 of pairs2) {
putU16s(out, [_176[0], _176[1]]);
}
Expand All @@ -139,7 +139,7 @@ export function edits(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void {
}
return undefined;
}));
rt.sliceSortBy(options, rt.cmpOption(rt.cmp));
rt.sliceSort(options, rt.cmpLt(rt.cmpOption(rt.cmp)));
for (const _215 of options) {
putU16s(out, [mapOr$Option_u16_u16_edits_closure21(_215, 65535, (o: rt.u16): rt.u16 => {
return o;
Expand All @@ -149,7 +149,7 @@ export function edits(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void {
const b6: rt.u8 = _216;
return text(rt.byteSliceFrom(Uint8Array.of(b6, rt.u8Div(b6, 16))));
}));
rt.sliceSortBy(names3, rt.cmpStr);
rt.sliceSort(names3, rt.cmpLt(rt.cmpStr));
for (const _234 of names3) {
put(out, _234);
}
Expand Down Expand Up @@ -213,8 +213,8 @@ export function edits(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void {
return rt.u16Add(i4 as rt.u16, b3 as rt.u16);
}));
}));
const _424: rt.u16[][] = rt.vecClone(nested, (a014: rt.u16[]): rt.u16[] => {
return a014.slice();
const _424: rt.u16[][] = rt.vecClone(nested, (a018: rt.u16[]): rt.u16[] => {
return a018.slice();
});
rt.byteVecPush(out, rt.eqSlice(rt.eqSlice(rt.same))(_424, nested) ? 1 : 0);
const pair: [string, rt.u8] = [text(data), at(0)];
Expand Down Expand Up @@ -255,16 +255,16 @@ export function edits(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void {
const x: Stamp.Stamp = _529[0];
const lo: Stamp.Stamp = _529[1];
const hi: Stamp.Stamp = _529[2];
rt.byteVecPush(out, rt.ordMax(x, lo, Stamp.partialCmp$PartialOrd)._0);
rt.byteVecPush(out, rt.ordMin(x, lo, Stamp.partialCmp$PartialOrd)._0);
rt.byteVecPush(out, rt.ordClamp(x, lo, hi, Stamp.partialCmp$PartialOrd)._0);
rt.byteVecPush(out, rt.ordMax(x, lo, rt.cmpLt(Stamp.partialCmp$PartialOrd))._0);
rt.byteVecPush(out, rt.ordMin(x, lo, rt.cmpLt(Stamp.partialCmp$PartialOrd))._0);
rt.byteVecPush(out, rt.ordClamp(x, lo, hi, rt.cmpLe(Stamp.partialCmp$PartialOrd), rt.cmpLt(Stamp.partialCmp$PartialOrd), rt.cmpGt(Stamp.partialCmp$PartialOrd))._0);
const _554: [Lean.Lean, Lean.Lean, Lean.Lean] = [{ _0: at(0) }, { _0: at(1) }, { _0: at(2) }];
const p: Lean.Lean = _554[0];
const q: Lean.Lean = _554[1];
const r: Lean.Lean = _554[2];
rt.byteVecPush(out, rt.ordMax(p, q, Lean.partialCmp$PartialOrd)._0);
rt.byteVecPush(out, rt.ordMin(p, q, Lean.partialCmp$PartialOrd)._0);
rt.byteVecPush(out, rt.ordClamp(p, q, r, Lean.partialCmp$PartialOrd)._0);
rt.byteVecPush(out, rt.ordMax(p, q, rt.cmpLt(Lean.partialCmp$PartialOrd))._0);
rt.byteVecPush(out, rt.ordMin(p, q, rt.cmpLt(Lean.partialCmp$PartialOrd))._0);
rt.byteVecPush(out, rt.ordClamp(p, q, r, rt.cmpLe(Lean.partialCmp$PartialOrd), rt.cmpLt(Lean.partialCmp$PartialOrd), rt.cmpGt(Lean.partialCmp$PartialOrd))._0);
} else {
const s: string = text(data);
const sep: rt.char[] = [47, 97];
Expand Down
4 changes: 2 additions & 2 deletions ts/fixtures/lang/expected/harness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { ints, strings, derived, written, counts, rounding, panics } from "./fmt
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 as ints_cast, convert } from "./ints.ts";
import { adaptors, consumers, skips, ranges, options, own, values } from "./iters.ts";
import { keys } from "./keys.ts";
import { keys, overrides } from "./keys.ts";
import { nested } from "./nested.ts";
import { refs } from "./refs.ts";
import { copies, order, discriminants, loops, patterns, closures, library, flows } from "./shapes.ts";
Expand Down Expand Up @@ -74,7 +74,7 @@ export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec)
counts(data22, out22);
}] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["fmt::rounding", (_232: rt.u8, _310: rt.ByteSlice, out23: rt.ByteVec): void => {
rounding(out23);
}] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["iters::skips", skips] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["wrappers::wrappers", wrappers] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["edits::edits", edits] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["utf8::decodes", decodes] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["floats::floats", floats] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["atomics::atomics", atomics] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void]];
}] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["iters::skips", skips] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["wrappers::wrappers", wrappers] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["edits::edits", edits] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["utf8::decodes", decodes] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["floats::floats", floats] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["atomics::atomics", atomics] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["keys::overrides", overrides] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void]];
}

/** Run one case. */
Expand Down
43 changes: 43 additions & 0 deletions ts/fixtures/lang/expected/keys.Lopsided.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Generated by rust2-ts. Do not edit.

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

export function eq$PartialEq(self: Lopsided, other: Lopsided): boolean {
return self._0 === other._0;
}

export function cmp$Ord(self: Lopsided, other: Lopsided): rt.Ordering {
return rt.cmp(self._0, other._0);
}

/**
* An `Ord` by value whose own `<`, `<=`, `>`, and `>=` each disagree with it: `<` and `>`
* reversed, `<=` by quarter and reversed, and `>=` by the value mod 4, so a test that std
* calls and the translation computes from `partial_cmp` shows. `<` is still a total
* order, which sorts need.
*/
export interface Lopsided {
_0: rt.u8;
}

export function partialCmp$PartialOrd(self: Lopsided, other: Lopsided): rt.Ordering | undefined {
return cmp$Ord(self, other);
}

export function lt$PartialOrd(self: Lopsided, other: Lopsided): boolean {
return self._0 > other._0;
}

export function le$PartialOrd(self: Lopsided, other: Lopsided): boolean {
return rt.u8Div(self._0, 4) >= rt.u8Div(other._0, 4);
}

export function gt$PartialOrd(self: Lopsided, other: Lopsided): boolean {
return self._0 < other._0;
}

export function ge$PartialOrd(self: Lopsided, other: Lopsided): boolean {
return rt.u8Rem(self._0, 4) >= rt.u8Rem(other._0, 4);
}

//# sourceMappingURL=keys.Lopsided.ts.map
Loading