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 @@ -33,6 +33,5 @@ generic std gap is planned here even when moq never calls it.
- [std iterators' Debug](/quest/m3/ts-iter-debug.md) - `{:?}` of std's iterators translates, writing std's text, a deque's two slices included
- [LinkedList](/quest/m3/ts-linked-list.md) - `LinkedList` and its methods translate
- [A parameter read only where lowering leaves nothing](/quest/m3/ts-unread-params.md) - an instance whose lowering drops every read of a parameter marks it unused, so `tsc` accepts it
- [std's impls of its zero-sized types](/quest/m3/ts-zero-sized-impls.md) - `PhantomData`'s derived impls translate, and `()` is a hash or B-tree key
- [Array keys a collection holds](/quest/m3/ts-array-keys.md) - collections of `[T; N]` keys type-check
- [Zip's next_back in constant time](/quest/m3/ts-zip-back.md) - a reversed zip of random-access iterators skips the longer side's excess at once
18 changes: 0 additions & 18 deletions quest/m3/ts-zero-sized-impls.md

This file was deleted.

1 change: 1 addition & 0 deletions ts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ crate translation reaches is refused, and so are two versions of one crate it re
| `u64`, `i64`, `u128`, `i128` | `rt.u64` and so on: a branded `number` while a safe integer, 32-bit limbs past 2^53, checked the same way |
| `f64` | `rt.f64`: a `number` branded so, which is the same IEEE 754 double |
| `f32` | `rt.f32`: a `number` branded so, which a single holds exactly |
| `()`, `PhantomData<T>`, `PhantomPinned`, `..` | `undefined`, every value equal and hashing nothing; a type parameter only a `PhantomData` holds is `_T` in its struct's interface |
| `struct` | a plain object, typed by an interface; a class if it may drop |
| `enum` without data | a union of strings: `"Lite01" \| "Lite02"`, or `never` without variants |
| `enum` | a union of objects tagged by variant |
Expand Down
22 changes: 22 additions & 0 deletions ts/fixtures/lang/expected/core/option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import type * as slices_Item from "../slices.Item.ts";
import * as slices_Noisy from "../slices.Noisy.ts";
import type * as slices_Pair from "../slices.Pair.ts";
import type * as Short from "../splits.Short.ts";
import * as Tagged from "../zeros.Tagged.ts";

export function isSomeAnd$09tpccf(self: rt.u8 | undefined, f: (a0: rt.u8) => boolean): boolean {
if (self === undefined) {
Expand Down Expand Up @@ -193,6 +194,13 @@ export function unwrapOrDefault$165pyh5(self: string | undefined): string {
return self;
}

export function unwrapOrDefault$1b97y1a(self: Tagged.Tagged<string> | undefined): Tagged.Tagged<string> {
if (self === undefined) {
return Tagged.default$Default_String();
}
return self;
}

export function unwrapOrDefault$0wx44sw(self: rt.ByteVec | undefined): rt.ByteVec {
if (self === undefined) {
return new rt.ByteVec();
Expand Down Expand Up @@ -370,6 +378,13 @@ export function map$1c7fhtg(self: rt.ByteVec | undefined, f: (a0: rt.ByteVec) =>
return f(self);
}

export function map$0po44cb(self: undefined[] | undefined, f: (a0: undefined[]) => Uint8Array): Uint8Array | undefined {
if (self === undefined) {
return undefined;
}
return f(self);
}

export function map$0lcwx9x(self: Way.Way | undefined, f: (a0: Way.Way) => boolean): boolean | undefined {
if (self === undefined) {
return undefined;
Expand Down Expand Up @@ -461,6 +476,13 @@ export function map$1k7m6zz(self: [rt.u8, rt.u8] | undefined, f: (a0: [rt.u8, rt
return f(self);
}

export function map$1iwwjee(self: rt.u8 | undefined, f: (a0: rt.u8) => Uint8Array): Uint8Array | undefined {
if (self === undefined) {
return undefined;
}
return f(self);
}

export function map$0p22lts(self: rt.u8 | undefined, f: (a0: rt.u8) => undefined): undefined | rt.None {
if (self === undefined) {
return rt.None;
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 @@ -43,7 +43,7 @@ import { statics, cells as statics_cells, onces } from "./statics.ts";
import { strs, slices, edits as strs_edits, parses as strs_parses, iters, drains as strs_drains, hinted } from "./strs.ts";
import { decodes } from "./utf8.ts";
import { wrappers } from "./wrappers.ts";
import { zeros } from "./zeros.ts";
import { zeros, impls, keys as zeros_keys } from "./zeros.ts";

/**
* Each case's name and what it runs. The first byte picks one modulo their count, so a
Expand Down Expand Up @@ -194,7 +194,7 @@ export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec)
lent(data70, out71);
}] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["floats::mul_adds", mulAdds as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["singles::mul_adds", singles_mulAdds as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["fmt::collections", (_2171: rt.u8, data71: rt.ByteSlice, out72: rt.ByteVec): undefined => {
collections(data71, out72);
}] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["collections::unlike_eqs", unlikeEqs as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]];
}] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["collections::unlike_eqs", unlikeEqs as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["zeros::impls", impls as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["zeros::keys", zeros_keys as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]];
}

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

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

export function clone$Clone(_self: Names): Names {
_self._0;
_self._1;
_self._2;
_self._3;
_self._4;
_self._5;
_self._6;
_self._7;
_self._8;
_self._9;
return { _0: undefined, _1: undefined, _2: undefined, _3: undefined, _4: undefined, _5: undefined, _6: undefined, _7: undefined, _8: undefined, _9: undefined };
}

export function fmt$Debug(_self: Names, f: rt.Formatter): rt.Result<undefined, rt.FmtError> {
const values: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtWriteStr(f, "PhantomData<u8>"), (f: rt.Formatter) => rt.fmtWriteStr(f, "PhantomData<alloc::string::String>"), (f: rt.Formatter) => rt.fmtWriteStr(f, "PhantomData<(i64, bool)>"), (f: rt.Formatter) => rt.fmtWriteStr(f, "PhantomData<&str>"), (f: rt.Formatter) => rt.fmtWriteStr(f, "PhantomData<[u16; 3]>"), (f: rt.Formatter) => rt.fmtWriteStr(f, "PhantomData<alloc::vec::Vec<core::option::Option<char>>>"), (f: rt.Formatter) => rt.fmtWriteStr(f, "PhantomData<fn(u8) -> u8>"), (f: rt.Formatter) => rt.fmtWriteStr(f, "PhantomData<lang_fixture::zeros::Unit>"), (f: rt.Formatter) => rt.fmtWriteStr(f, "PhantomData<lang_fixture::zeros::Tagged<()>>"), (f: rt.Formatter) => rt.fmtWriteStr(f, "PhantomData<()>")];
return rt.fmtDebugTupleFields(f, "Names", values);
}

export function default$Default(): Names {
undefined;
undefined;
undefined;
undefined;
undefined;
undefined;
undefined;
undefined;
undefined;
undefined;
return { _0: undefined, _1: undefined, _2: undefined, _3: undefined, _4: undefined, _5: undefined, _6: undefined, _7: undefined, _8: undefined, _9: undefined };
}

export function eq$PartialEq(_self: Names, _other: Names): boolean {
if (true) {
if (true) {
if (true) {
if (true) {
if (true) {
if (true) {
if (true) {
if (true) {
if (true) {
return true;
}
}
}
}
}
}
}
}
}
return false;
}

export function cmp$Ord(_self: Names, _other: Names): rt.Ordering {
const cmp: rt.Ordering = rt.cmpNothing(_self._0, _other._0);
if (cmp === 0) {
const cmp2: rt.Ordering = rt.cmpNothing(_self._1, _other._1);
if (cmp2 === 0) {
const cmp3: rt.Ordering = rt.cmpNothing(_self._2, _other._2);
if (cmp3 === 0) {
const cmp4: rt.Ordering = rt.cmpNothing(_self._3, _other._3);
if (cmp4 === 0) {
const cmp5: rt.Ordering = rt.cmpNothing(_self._4, _other._4);
if (cmp5 === 0) {
const cmp6: rt.Ordering = rt.cmpNothing(_self._5, _other._5);
if (cmp6 === 0) {
const cmp7: rt.Ordering = rt.cmpNothing(_self._6, _other._6);
if (cmp7 === 0) {
const cmp8: rt.Ordering = rt.cmpNothing(_self._7, _other._7);
if (cmp8 === 0) {
const cmp9: rt.Ordering = rt.cmpNothing(_self._8, _other._8);
if (cmp9 === 0) {
return rt.cmpNothing(_self._9, _other._9);
}
return cmp9;
}
return cmp8;
}
return cmp7;
}
return cmp6;
}
return cmp5;
}
return cmp4;
}
return cmp3;
}
return cmp2;
}
return cmp;
}

export function hash$Hash_DefaultHasher(_self: Names, state: rt.Hasher): void {
rt.hashNothing(_self._0, state);
rt.hashNothing(_self._1, state);
rt.hashNothing(_self._2, state);
rt.hashNothing(_self._3, state);
rt.hashNothing(_self._4, state);
rt.hashNothing(_self._5, state);
rt.hashNothing(_self._6, state);
rt.hashNothing(_self._7, state);
rt.hashNothing(_self._8, state);
rt.hashNothing(_self._9, state);
}

/** `PhantomData` of several types, whose `Debug` names each. */
export interface Names {
_0: undefined;
_1: undefined;
_2: undefined;
_3: undefined;
_4: undefined;
_5: undefined;
_6: undefined;
_7: undefined;
_8: undefined;
_9: undefined;
}

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

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

export function clone$Clone(self: Rest): Rest {
self._0;
rt.iterEmpty() as rt.Iter<rt.u8>;
return { _0: undefined, _1: rt.iterEmpty() as rt.Iter<rt.u8> };
}

export function fmt$Debug(self: Rest, f: rt.Formatter): rt.Result<undefined, rt.FmtError> {
const _3: string = "Rest";
const _4: rt.Fmt = (f: rt.Formatter) => rt.fmtRangeFull(self._0, f);
const _6: rt.Fmt = (f: rt.Formatter) => rt.fmtWriteStr(f, "Empty");
return rt.debugTupleFinish(rt.debugTupleField(rt.debugTupleField(rt.fmtDebugTuple(f, _3), _4), _6));
}

export function default$Default(): Rest {
undefined;
rt.iterEmpty() as rt.Iter<rt.u8>;
return { _0: undefined, _1: rt.iterEmpty() as rt.Iter<rt.u8> };
}

/** `..` and `Empty`, whose impls are std's own, of what each has. */
export interface Rest {
_0: undefined;
_1: rt.Iter<rt.u8>;
}

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

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

export function clone$Clone_String(self: Tagged<string>): Tagged<string> {
const _2: rt.u8 = self.n;
self.of;
self.pin;
return { n: _2, of: undefined, pin: undefined, unit: undefined };
}

export function fmt$Debug_String(self: Tagged<string>, f: rt.Formatter): rt.Result<undefined, rt.FmtError> {
const _3: string = "Tagged";
const _4: string = "n";
const _5: rt.Fmt = (f: rt.Formatter) => rt.u8Debug(self.n, f);
const _7: string = "of";
const _8: rt.Fmt = (f: rt.Formatter) => rt.fmtWriteStr(f, "PhantomData<alloc::string::String>");
const _10: string = "pin";
const _11: rt.Fmt = (f: rt.Formatter) => rt.fmtWriteStr(f, "PhantomPinned");
const _13: string = "unit";
const _14: rt.Fmt = (f: rt.Formatter) => rt.fmtUnit(self.unit, f);
return rt.debugStructFinish(rt.debugStructField(rt.debugStructField(rt.debugStructField(rt.debugStructField(rt.fmtDebugStruct(f, _3), _4, _5), _7, _8), _10, _11), _13, _14));
}

export function fmt$Debug_u8(self: Tagged<rt.u8>, f: rt.Formatter): rt.Result<undefined, rt.FmtError> {
const _3: string = "Tagged";
const _4: string = "n";
const _5: rt.Fmt = (f: rt.Formatter) => rt.u8Debug(self.n, f);
const _7: string = "of";
const _8: rt.Fmt = (f: rt.Formatter) => rt.fmtWriteStr(f, "PhantomData<u8>");
const _10: string = "pin";
const _11: rt.Fmt = (f: rt.Formatter) => rt.fmtWriteStr(f, "PhantomPinned");
const _13: string = "unit";
const _14: rt.Fmt = (f: rt.Formatter) => rt.fmtUnit(self.unit, f);
return rt.debugStructFinish(rt.debugStructField(rt.debugStructField(rt.debugStructField(rt.debugStructField(rt.fmtDebugStruct(f, _3), _4, _5), _7, _8), _10, _11), _13, _14));
}

export function default$Default_String(): Tagged<string> {
const _1: rt.u8 = 0;
undefined;
undefined;
undefined;
return { n: _1, of: undefined, pin: undefined, unit: undefined };
}

export function default$Default_u8(): Tagged<rt.u8> {
const _1: rt.u8 = 0;
undefined;
undefined;
undefined;
return { n: _1, of: undefined, pin: undefined, unit: undefined };
}

export function eq$PartialEq_String(self: Tagged<string>, other: Tagged<string>): boolean {
if (self.n === other.n) {
if (true) {
if (true) {
return true;
}
}
}
return false;
}

export function partialCmp$PartialOrd_String(self: Tagged<string>, other: Tagged<string>): rt.Ordering | undefined {
const cmp: rt.Ordering | undefined = rt.cmp(self.n, other.n);
if (cmp !== undefined) {
if (cmp === 0) {
const cmp2: rt.Ordering | undefined = rt.cmpNothing(self.of, other.of);
if (cmp2 !== undefined) {
if (cmp2 === 0) {
const cmp3: rt.Ordering | undefined = rt.cmpNothing(self.pin, other.pin);
if (cmp3 !== undefined) {
if (cmp3 === 0) {
return rt.cmpNothing(self.unit, other.unit);
}
}
return cmp3;
}
}
return cmp2;
}
}
return cmp;
}

export function cmp$Ord_String(self: Tagged<string>, other: Tagged<string>): rt.Ordering {
const cmp: rt.Ordering = rt.cmp(self.n, other.n);
if (cmp === 0) {
const cmp2: rt.Ordering = rt.cmpNothing(self.of, other.of);
if (cmp2 === 0) {
const cmp3: rt.Ordering = rt.cmpNothing(self.pin, other.pin);
if (cmp3 === 0) {
return rt.cmpNothing(self.unit, other.unit);
}
return cmp3;
}
return cmp2;
}
return cmp;
}

export function hash$Hash_String_DefaultHasher(self: Tagged<string>, state: rt.Hasher): void {
rt.hash8(self.n, state);
rt.hashNothing(self.of, state);
rt.hashNothing(self.pin, state);
rt.hashNothing(self.unit, state);
}

/** Each derivable impl, on fields of std's zero-sized types beside one that isn't. */
export interface Tagged<_T> {
n: rt.u8;
of: undefined;
pin: undefined;
unit: undefined;
}

//# sourceMappingURL=zeros.Tagged.ts.map
Loading