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
6 changes: 3 additions & 3 deletions quest/m2/ts-shared.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ guard's drop unlocks it, `try_lock` while held gives `WouldBlock`, and a re-entr
upgrades once the function returns. `rt.Atomic` holds a `bool` or an integer, and its
operations check their orderings as std does. `rt.OnceCell` and `rt.OnceLock` hold
their `Option<T>`, and a `OnceLock` initialized from within its own initialization panics as wasm32's does;
their `Clone`, `Debug`, `PartialEq`, `get_mut`, and `get_or_try_init` are still refused.
their `Clone`, `Debug`, `get_mut`, and `get_or_try_init` are still refused.
`rt.Cell` is the place that holds its value. `rt.RefCell`, a `RefCell` or an `RwLock`,
is its own guard and counts its borrows: a conflicting borrow panics, and a conflicting
lock aborts, each with wasm32's message. Their `get_mut`, `into_inner`, `try_borrow`,
`Ref::map`, and `Ref::clone` are still refused.
lock aborts, each with wasm32's message. Their `Clone`, `get_mut`, `into_inner`,
`try_borrow`, `Ref::map`, and `Ref::clone` are still refused.
A `thread_local!` key is an `rt.LocalKey`, a module's value that makes its value on
first use, as wasm32's `LazyStorage` does, and never drops it. A `static` atomic is a
module's value too, an `rt.Atomic` of the value the static's memory starts with.
Expand Down
1 change: 0 additions & 1 deletion quest/m3/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,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
- [A deque's two slices](/quest/m3/ts-deque-slices.md) - `VecDeque::as_slices` and `{:?}` of a deque's `Iter`, `IterMut`, and `Drain` translate, split where std's are
- [Equality of Cell and RefCell](/quest/m3/ts-eq-cells.md) - `==` and `!=` of `Cell`s and `RefCell`s translate
- [Cow of a slice, and Wrapping](/quest/m3/ts-cow-slices.md) - `Cow<[T]>` and `Wrapping<T>` translate, `PartialEq` included
- [LinkedList](/quest/m3/ts-linked-list.md) - `LinkedList` and its methods translate
- [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
Expand Down
15 changes: 0 additions & 15 deletions quest/m3/ts-eq-cells.md

This file was deleted.

10 changes: 6 additions & 4 deletions ts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,9 @@ number, string, or boolean in a JS `Map`, which compares those as Rust's `Eq` do
finds any other key, a 64-bit one past 2^53 included, through its translated `Hash` and
`Eq`; a B-tree orders every key by its translated `Ord`. std's impls are the runtime's: an
`Option` orders `None` first, an `Arc` compares, orders, and hashes as what it holds,
so a map of `Arc<str>` finds a `&str`, and arrays, slices, and vectors, of bytes or of
other elements, order by their elements and then their length, and compare and hash alike
so a map of `Arc<str>` finds a `&str`, a `Cell` and a `RefCell` compare and order as
what they hold, a `RefCell` borrowing each, a one-time cell compares its `Option`, and
arrays, slices, and vectors, of bytes or of other elements, order by their elements and then their length, and compare and hash alike
whatever their form, so a map of `Vec<u8>` finds a `&[u8]` and one of `[u16; 2]` a `&[u16]`.
Slices, arrays, `Vec`s, and `VecDeque`s compare against each
other as std's do, by their lengths and then each pair of items in order, through the
Expand Down Expand Up @@ -714,8 +715,9 @@ built natively for wasm32 and run beside its translation on the same inputs by
closures that log what each
adaptor reads, `Option`'s and `Result`'s combinators, with closures that log each call,
and std's collections, over keys whose own `Hash`, `Eq`, and `Ord`
disagree with JS's, sequences, tuples, and `Arc`s compared across forms and item types by an
`eq` and `ne` that disagree, `vec![x; n]` of types whose `Clone` counts its clones, `&mut`
disagree with JS's, sequences, tuples, `Arc`s, and cells compared across forms and item
types by an `eq` and `ne` that disagree, a `RefCell` compared while mutably borrowed,
`vec![x; n]` of types whose `Clone` counts its clones, `&mut`
to values JS copies, of locals, fields, elements, and a map's values, passed on,
returned, kept in a struct, and captured, a `Vec`'s edits and sorts, with closures
that log what each is called with, std's `Bound`, `Reverse`, and `NonZero`, and raw
Expand Down
68 changes: 68 additions & 0 deletions ts/fixtures/lang/expected/collections.Quirky.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// Generated by rust2-ts. Do not edit.

import * as rt from "./rt.ts";
import { then$0wlzj76 } from "./core/bool.ts";

/**
* An item whose `ne` and `PartialOrd`'s tests see other remainders than its `eq` and
* `partial_cmp`, and whose `cmp` yet another, so what each comparison finds tells which
* std calls. Each call adds to the log, in order.
*/
export interface Quirky {
_0: rt.u16;
_1: rt.Cell<rt.u16>;
}

export function log(self: Quirky, other: Quirky, by: rt.u16): void {
rt.cellSet(self._1, rt.u16WrappingAdd(rt.u16WrappingMul(self._1.v, 31), self._0 ^ ((other._0 << 4) & 0xffff) ^ by));
}

export function eq$PartialEq(self: Quirky, other: Quirky): boolean {
log(self, other, 256);
return rt.u16Rem(self._0, 4) === rt.u16Rem(other._0, 4);
}

export function ne$PartialEq(self: Quirky, other: Quirky): boolean {
log(self, other, 512);
return rt.u16Rem(self._0, 3) !== rt.u16Rem(other._0, 3);
}

export function partialCmp$PartialOrd(self: Quirky, other: Quirky): rt.Ordering | undefined {
let _4!: boolean;
log(self, other, 768);
if (!(rt.u16Rem(self._0, 7) !== 0)) {
_4 = false;
} else {
_4 = rt.u16Rem(other._0, 7) !== 0;
}
return then$0wlzj76(_4, (): rt.Ordering => {
return rt.cmp(rt.u16Rem(self._0, 5), rt.u16Rem(other._0, 5));
});
}

export function lt$PartialOrd(self: Quirky, other: Quirky): boolean {
log(self, other, 1024);
return rt.u16Rem(self._0, 6) < rt.u16Rem(other._0, 6);
}

export function le$PartialOrd(self: Quirky, other: Quirky): boolean {
log(self, other, 1280);
return rt.u16Rem(self._0, 6) <= rt.u16Rem(other._0, 6);
}

export function gt$PartialOrd(self: Quirky, other: Quirky): boolean {
log(self, other, 1536);
return rt.u16Rem(self._0, 6) > rt.u16Rem(other._0, 6);
}

export function ge$PartialOrd(self: Quirky, other: Quirky): boolean {
log(self, other, 1792);
return rt.u16Rem(self._0, 6) >= rt.u16Rem(other._0, 6);
}

export function cmp$Ord(self: Quirky, other: Quirky): rt.Ordering {
log(self, other, 2048);
return rt.cmp(rt.u16Rem(self._0, 8), rt.u16Rem(other._0, 8));
}

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