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 @@ -26,7 +26,6 @@ generic std gap is planned here even when moq never calls it.
- [Waiting: a slice object for a mutable part of other values](/quest/m3/ts-slice-object.md) - waits on a moq profile showing the `Proxy` view's traps matter, then decides on an `rt.ByteSlice`-like form
- [Port the workflow guard to kixelated/quest](/quest/m3/quest-workflow-guard.md) - quest's environment guard parses YAML as this repository's does
- [Debug of a str's searches](/quest/m3/ts-iter-source-debug.md) - `Debug` of `str`'s `Split` and its forms, `Matches`, `Lines`, and `SplitWhitespace` writes their searcher's state as std's does
- [A B-tree's extract_if](/quest/m3/ts-btree-extract-if.md) - `BTreeMap::extract_if` and `BTreeSet::extract_if` translate, with their `Debug`
- [A vector keeps the capacity its pushes grew as it shrinks](/quest/m3/ts-vec-clear-capacity.md) - every step that drops a pushed `Vec`'s length keeps its capacity, as std guarantees
- [A vector's exact capacity as it shrinks](/quest/m3/ts-vec-exact-capacity.md) - a deque made from a `Vec` splits its slices where std's does
- [A string's exact capacity](/quest/m3/ts-string-capacity.md) - a `String` holds std's capacity, so a program making a `Bytes` of one reads its capacity
Expand Down
15 changes: 0 additions & 15 deletions quest/m3/ts-btree-extract-if.md

This file was deleted.

3 changes: 2 additions & 1 deletion quest/m3/ts-btree-search-order.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

[rust2-ts](/ts/README.md)'s `BTreeMap` and `BTreeSet` call a key's own `Ord::cmp` in the
order and number std's do in `insert`, `get`, `remove`, `extend`, `range`, and the set
operators that search, and answer the same where the tree is out of `Ord`'s order, as a
operators that search, and none where std's call none, as `pop_first`, `pop_last`, and
`extract_if` remove and rebalance, and answer the same where the tree is out of `Ord`'s order, as a
`collect` sorted by a disagreeing `PartialOrd::lt` leaves it, proven by differential tests
against native Rust with a logging `Ord`.

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

## Unreleased

- `rt.boundsOf` returns a record of the range's `startBound` and `endBound`, each read as
it is called, rather than a function reading both, which `rt.Bounds` takes as before.
- `rt.ArcWaker` is gone: `Waker::from(arc)` is `rt.arcWaker(arc, wake, drop, wakeByRef?)`.
An `rt.WakerVTable` is the record of the four functions std's `RawWakerVTable` holds,
`clone`, `wake`, `wakeByRef`, and `drop`, each called on a waker's `data`, so a
Expand Down
8 changes: 4 additions & 4 deletions ts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ crate translation reaches is refused, and so are two versions of one crate it re
| an iterator | `rt.Iter<Item>`, whose adaptors are runtime functions: `rt.iterMap(rt.iterSlice(v), f)` |
| `a..b`, `a..=b` | `rt.Range<T>`, `rt.RangeInclusive<T>`, which are iterators too |
| `a..`, `..b`, `..=b`, `Bound<T>` | `{ start }`, `{ end }`, `{ end, inclusive: true }`; `rt.RangeBound<T>`, a union tagged by variant |
| a range a drain or a B-tree's `range` takes | itself, or of a type other than std's ranges and a pair of `Bound`s, `rt.boundsOf` of it and its `start_bound` and `end_bound`, which the runtime calls where std's does; one that drops, the parameter of the call `rt.dropAfter` makes, which drops it once the call returns, as std drops it before it does anything JS can see |
| a range a drain or a B-tree's `range` or `extract_if` takes | itself, or of a type other than std's ranges and a pair of `Bound`s, `rt.boundsOf` of it and its `start_bound` and `end_bound`, which the runtime calls where std's does; one that drops, the parameter of the call `rt.dropAfter` makes, which drops it once the call returns, as std drops it before it does anything JS can see, or of an `extract_if`, which holds it, the parameter of a call that hands its iterator what drops it after its closure |
| `HashMap`, `HashSet`, `BTreeMap`, `BTreeSet`, `VecDeque`, `LinkedList`, `BinaryHeap` | `rt.HashMap<K, V>` and so on, each a plain object whose functions are the runtime's: `rt.hashGet(map, key)` |
| `PeekMut<T>` | `rt.PeekMut<T>`, the `rt.Place` of a heap's greatest element, which sifts it down as it drops once `DerefMut` lent it |
| `Ordering`, `DefaultHasher`, `RandomState`, `BuildHasherDefault<H>` | `rt.Ordering`, which is `-1`, `0`, or `1`; `rt.Hasher`; `rt.RandomState`, the keys of the `DefaultHasher` it builds, never changed once made; `undefined`, as `PhantomData` is, whose `build_hasher` is `H::default()` |
Expand Down Expand Up @@ -309,8 +309,8 @@ iterators, a `CharIndices`, a `String`'s `Drain`, and a slice's `Windows`, chunk
splits, each writing what is left of its slice as std's does, emptied where std's `nth` past
the end empties a `Windows`; a hash set's operations write the list a clone yields, and a
`BTreeSet`'s the way std picked to make each, by the iterators it reads, the set it looks
keys up in, and the key it peeked or holds back. A list's `ExtractIf` writes the item it
reads next, and a hash map's and set's nothing. A slice's `chunks_mut` and its forms are
keys up in, and the key it peeked or holds back. A list's and a B-tree's `ExtractIf` write
the item or entry it reads next, until it stops, and a hash map's and set's nothing. A slice's `chunks_mut` and its forms are
refused, as std writes their slice's address, and so are a `str`'s searches, `Split` and
its forms, `Matches`, `MatchIndices`, `Lines`, and `SplitWhitespace`, as std writes its
searcher's state in UTF-8 bytes. `Debug` of `Bound`, `Ordering`, `Reverse`, `AssertUnwindSafe`, and `ControlFlow` is
Expand Down Expand Up @@ -773,7 +773,7 @@ a translation replaces it.
A bound type keys a collection, alone or in a tuple, `Option`, or `Arc`, by the exports of
its Rust impls: `hash$Hash(self, state: rt.Hasher): undefined` and `eq$cmp_PartialEq` for a
`HashMap` or `HashSet`, `cmp$cmp_Ord` for a `BTreeMap` or `BTreeSet`, and
`partialCmp$cmp_PartialOrd` too for a B-tree's `range`. A derived impl's are the same exports.
`partialCmp$cmp_PartialOrd` too for a B-tree's `range` and `extract_if`. A derived impl's are the same exports.
Each must agree with the Rust impl: `hash` writes what it writes, through `rt.hash8` to
`rt.hash128`, `rt.hashI8` to `rt.hashI128`, `rt.hashUsize`, `rt.hashIsize`, `rt.hashStr`,
and `rt.hashBytes`, so values `eq` finds equal hash alike, and
Expand Down
52 changes: 52 additions & 0 deletions ts/fixtures/lang/collections/expected/collections.Logged.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Generated by rust2-ts. Do not edit.

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

/**
* A B-tree key ordered by its number's low byte, whose `PartialOrd`'s `le` and `lt`, which
* std checks a range's end by, see only that byte halved. Each of those and its drop add its
* whole number to the log.
*/
export class Logged {
_0: rt.u16;
_1: rt.RefCell<rt.u16[]>;

constructor(_0: rt.u16, _1: rt.RefCell<rt.u16[]>) {
this._0 = _0;
this._1 = _1;
}

[Symbol.dispose](): void {
drop$ops_Drop(this);
}
}

export function drop$ops_Drop(self: Logged): void {
const _5: rt.RefCell<rt.u16[]> = rt.refCellBorrowMut(self._1);
_5.value.push(self._0);
rt.refMutRelease(_5);
}

export function eq$cmp_PartialEq(self: Logged, other: Logged): boolean {
return (self._0 & 255) === (other._0 & 255);
}

export function le$cmp_PartialOrd(self: Logged, other: Logged): boolean {
const _6: rt.RefCell<rt.u16[]> = rt.refCellBorrowMut(self._1);
_6.value.push(16384 | self._0);
rt.refMutRelease(_6);
return rt.u16Div(self._0 & 255, 2) <= rt.u16Div(other._0 & 255, 2);
}

export function lt$cmp_PartialOrd(self: Logged, other: Logged): boolean {
const _6: rt.RefCell<rt.u16[]> = rt.refCellBorrowMut(self._1);
_6.value.push(8192 | self._0);
rt.refMutRelease(_6);
return rt.u16Div(self._0 & 255, 2) < rt.u16Div(other._0 & 255, 2);
}

export function cmp$cmp_Ord(self: Logged, other: Logged): rt.Ordering {
return rt.cmp(self._0 & 255, other._0 & 255);
}

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

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

/** A range of its own, which logs each read of either bound. */
export interface Window {
lo: rt.u16;
hi: rt.u16;
log: rt.RefCell<rt.u16[]>;
}

export function startBound$ops_RangeBounds_u16(self: Window): rt.RangeBound<rt.u16> {
const _5: rt.RefCell<rt.u16[]> = rt.refCellBorrowMut(self.log);
_5.value.push(40960);
rt.refMutRelease(_5);
return { tag: "Included", _0: self.lo } as rt.RangeBound<rt.u16>;
}

export function endBound$ops_RangeBounds_u16(self: Window): rt.RangeBound<rt.u16> {
const _5: rt.RefCell<rt.u16[]> = rt.refCellBorrowMut(self.log);
_5.value.push(45056);
rt.refMutRelease(_5);
return { tag: "Excluded", _0: self.hi } as rt.RangeBound<rt.u16>;
}

//# sourceMappingURL=collections.Window.ts.map
Loading