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: 1 addition & 0 deletions quest/m2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ The fork's feature quests folded into the [exporter](/quest/m1/ffi-export.md);
- [Shared ownership](/quest/m2/ts-shared.md) - `Arc`/`Rc`/`Weak` keep exact counts, and locks and atomics become plain values
- [Share what the crate never changes in place](/quest/m2/ts-shared-read.md) - copies of `Copy` aggregates no one writes into in place go away, recovering #83's decode cost
- [Matches TypeScript has already narrowed](/quest/m2/ts-narrow-test.md) - an inner match on a value an outer match decided passes `tsc`
- [Small std gaps](/quest/m2/ts-std-gaps.md) - `bool::then`, `iter::successors`, `usize::from(bool)`, and `None.ok_or` narrowing
- [Copy-on-write strings](/quest/m2/ts-cow-str.md) - `Cow<str>` translates, finishing `ietf/namespace.rs`
- [Translate moq-net's model to TypeScript](/quest/m2/ts-model.md) - the driver grows from moq-net's codec to its model, for moq to compare against WASM
- [Waiting: Swift 6.4 in nixpkgs-unstable](/quest/m2/uniffi-swift-arm.md) - the nightly UniFFI fixtures move back to arm
Expand Down
19 changes: 19 additions & 0 deletions quest/m2/ts-std-gaps.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# [S] Small std gaps

## Goal

rust2-ts translates `bool::then`, `bool::then_some`, `iter::successors`, and
`usize::from(bool)`, and `None.ok_or(e)` passes `tsc` where TypeScript narrowed the
value to `undefined`, so `discovery.rs`'s parent walk translates, proven by differential
tests against native Rust.

## Plan

Found by [#87](https://github.com/kixelated/rust2/pull/87) and
[#106](https://github.com/kixelated/rust2/pull/106) on 2026-10-27.

- `then` calls its closure only when true, and `successors` calls its closure only for
the next item it yields; cover both laziness points in the differential tests.
Comment on lines +15 to +16

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Specify Rust's actual successor evaluation timing

When iteration stops early, successors still evaluates a successor that is never yielded: each successful next() invokes the closure on the current item before returning that item. For example, native Rust's successors(Some(0), |n| { calls += 1; Some(n + 1) }).take(1) increments calls once despite yielding only the initial value. Requiring closure calls only for items actually yielded would therefore produce incorrect side effects and panic timing. Amend the plan and differential tests to preserve this eager one-item lookahead, as required by the repository's exact-semantics rule.

AGENTS.md reference: AGENTS.md:L15-L15

Useful? React with 👍 / 👎.

- Report moq-net's census before and after.

Public API: the translator's output.