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 @@ -32,6 +32,5 @@ generic std gap is planned here even when moq never calls it.
- [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
- [Cycling std's iterators](/quest/m3/ts-iter-cycle.md) - `Iterator::cycle` translates, cloning its iterator each time it ends
- [Debug of Bound](/quest/m3/ts-bound-debug.md) - `{:?}` of a `Bound`, as a range's `start_bound` gives, translates
- [Orderings by a crate's impl on references](/quest/m3/ts-ord-ref-impls.md) - a tuple, `Option`, or slice of `&T` orders by the crate's `PartialOrd` for `&T`
17 changes: 0 additions & 17 deletions quest/m3/ts-iter-cycle.md

This file was deleted.

6 changes: 4 additions & 2 deletions ts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,9 @@ owns its items holds, an adaptor's closure, or the crate's own iterator, it clon
what the translation gives it, as `it.clone({ v: Item.clone$Clone })`. A closure clones as Rust
clones its captures: one that writes none of them, each of which only copies or clones
as itself, is its own clone, and another whose clone translation reaches is made by a
function of its captures, which makes the clone again of theirs, in order.
function of its captures, which makes the clone again of theirs, in order. `cycle` takes
the same clones, as `rt.iterCycle(it, { v: Item.clone$Clone })`, by which it clones its
iterator as it is made and again each time a clone ends.

A `str` is a JS string, which is UTF-16: `chars` steps by code point, and a search by a
`char`, a `&str`, a predicate, or an array or slice of chars, as in `rt.strSplit(s, "/")`, takes the text or the
Expand Down Expand Up @@ -678,7 +680,7 @@ that can be `undefined`, a collection's `capacity`, looking up a key by
another type it borrows as through the crate's own `Borrow`, a `&mut` to a value JS
copies that std makes, other than a map's, or hands a closure, as `iter_mut` and
`and_modify` do, one into a `Result`'s payload passed on or kept, `Hasher::write` of bytes, the adaptors
without a mapping in `src/lower/iter.rs` (such as `cycle`, `unzip`, and `partition`), an
without a mapping in `src/lower/iter.rs` (such as `unzip` and `partition`), an
own `impl Iterator` with `next_back`, `len`, or another provided method of its own,
a pointer's address (`{:p}`), `write!` with a placeholder into
the crate's own `fmt::Write`, a `str` pattern other than a
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 @@ -16,6 +16,7 @@ import type * as counts_Noisy from "../counts.Noisy.ts";
import type * as RcNode from "../counts.RcNode.ts";
import type * as RcShared from "../counts.RcShared.ts";
import type * as Twin from "../counts.Twin.ts";
import type * as cycles_Logged from "../cycles.Logged.ts";
import * as Made from "../defaults.Made.ts";
import type * as Shape from "../dyns.Shape.ts";
import * as Named from "../edits.Named.ts";
Expand Down Expand Up @@ -308,6 +309,13 @@ export function map$003seos(self: slices_Item.Item | undefined, f: (a0: slices_I
return f(self);
}

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

export function map$1u8sh4f(self: Named.Named | undefined, _: (a0: Named.Named) => Named.Named[]): Named.Named[] | undefined {
if (self === undefined) {
return undefined;
Expand Down Expand Up @@ -542,6 +550,13 @@ export function map$0gl6wke(self: [rt.usize, string] | undefined, f: (a0: [rt.us
return f(self);
}

export function map$05nbzug(self: rt.usize | undefined, f: (a0: rt.usize) => rt.u8): rt.u8 | undefined {
if (self === undefined) {
return undefined;
}
return f(self);
}

export function inspect$0di0vx1(self: rt.u8 | undefined, f: (a0: rt.u8) => undefined): rt.u8 | undefined {
if (self !== undefined) {
f(self);
Expand Down Expand Up @@ -626,6 +641,13 @@ export function mapOr$1yabfom(self: Logged.Logged | undefined, default_: rt.u8,
return Logged.id(self);
}

export function mapOr$0djjvgl(self: cycles_Logged.Logged | undefined, default_: rt.u8, f: (a0: cycles_Logged.Logged) => rt.u8): rt.u8 {
if (self === undefined) {
return default_;
}
return f(self);
}

export function mapOr$1ybqvup(self: Meters.Meters | undefined, default_: rt.u64, f: (a0: Meters.Meters) => rt.u64): rt.u64 {
if (self === undefined) {
return default_;
Expand Down
23 changes: 23 additions & 0 deletions ts/fixtures/lang/expected/cycles.Countdown.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Generated by rust2-ts. Do not edit.

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

export function clone$Clone(self: Countdown): Countdown {
return { _0: self._0 };
}

/** The crate's own iterator, which `cycle` clones by its `Clone`. */
export interface Countdown {
_0: rt.u8;
}

export function next$Iterator(self: Countdown): rt.u8 | rt.Done {
const _2: rt.u8 | undefined = rt.u8CheckedSub(self._0, 1);
if (_2 !== undefined) {
self._0 = _2;
return self._0;
}
return rt.DONE;
}

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

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

/**
* Logs its id as it drops, and as it is cloned, the id with the high bit set: its clone's
* id is one more.
*/
export class Logged {
id: rt.u8;
log: rt.Arc<rt.RefCell<rt.ByteVec>>;

constructor(id: rt.u8, log: rt.Arc<rt.RefCell<rt.ByteVec>>) {
this.id = id;
this.log = log;
}

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

export function id(self: Logged): rt.u8 {
return self.id;
}

/** Logs `x`, as a closure that holds it is called. */
export function called(self: Logged, x: rt.u8): rt.u8 {
const _6: rt.RefCell<rt.ByteVec> = rt.refCellBorrowMut(self.log.value);
rt.byteVecPush(_6.value, 64 | (x & 63));
rt.refMutRelease(_6);
return x ^ self.id;
}

export function clone$Clone(self: Logged): Logged {
const _5: rt.RefCell<rt.ByteVec> = rt.refCellBorrowMut(self.log.value);
rt.byteVecPush(_5.value, 128 | self.id);
rt.refMutRelease(_5);
return new Logged(rt.u8WrappingAdd(self.id, 1), rt.arcClone(self.log));
}

export function drop$Drop(self: Logged): void {
const _5: rt.RefCell<rt.ByteVec> = rt.refCellBorrowMut(self.log.value);
rt.byteVecPush(_5.value, self.id);
rt.refMutRelease(_5);
}

//# sourceMappingURL=cycles.Logged.ts.map
Loading