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
2 changes: 1 addition & 1 deletion quest/m3/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ generic std gap is planned here even when moq never calls it.
- [Relink without rebuilding](/quest/m3/relink.md) - measure upstream's skip of dependency-only rebuilds on moq's edits once it reaches nightly
- [Unsafe code the translator can model](/quest/m3/ts-unsafe.md) - a dependency using only `unsafe` the translator can model translates from source
- [f32](/quest/m3/ts-f32.md) - `f32` and `Duration`'s `f32` methods translate as `f64` does
- [A mutable reference to a reference](/quest/m3/ts-mut-ref.md) - `&mut &[u8]` and `&mut &mut T` translate, so `Buf` of a `&[u8]` and `bytes`' forwarding impls do
- [The capacity of a BytesMut](/quest/m3/ts-bytes-capacity.md) - `BytesMut::capacity` and what reads it translate with `bytes`' values
- [BufMut's provided writes through a &mut](/quest/m3/ts-buf-mut-forward.md) - `put`, `put_bytes`, `put_uint`, and `put_int` of a `&mut Vec<u8>` or `&mut BytesMut` translate
- [Trait objects](/quest/m3/ts-dyn.md) - `dyn Error`, `dyn Iterator`, `dyn Buf`, and `Arc<dyn Debug>` translate, so a consumer neither rewrites nor binds them
Expand All @@ -27,5 +26,6 @@ generic std gap is planned here even when moq never calls it.
- [Binding gaps](/quest/m3/ts-bind-gaps.md) - bound types as keys, unit returns checked, renamed dependencies
- [Drop order in std's folds and iterators](/quest/m3/ts-drop-order.md) - the values that drop still refused in std's folds, zips, flattens, and collects drop as std's do
- [Ordering in std](/quest/m3/ts-ordering.md) - `cmp::max`/`min`, `is_sorted`, and `BinaryHeap`, and #173's cost on integers measured
- [Return a std iterator's next from a generic function](/quest/m3/ts-next-return.md) - `it.next()` returned from a generic function is an `Option`, as `tsc` expects
- [Into targets through a chain of From implementations](/quest/m3/ffi-from-chains.md) - `sources` follows more than one level, once a consumer's parameter needs it
- [Port the workflow guard to kixelated/quest](/quest/m3/quest-workflow-guard.md) - quest's environment guard parses YAML as this repository's does
25 changes: 0 additions & 25 deletions quest/m3/ts-mut-ref.md

This file was deleted.

15 changes: 15 additions & 0 deletions quest/m3/ts-next-return.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# [S] Return a std iterator's next from a generic function

## Goal

rust2-ts translates a generic function that returns `next` of a std iterator it was given,
`fn first<I: Iterator<Item = u8>>(mut it: I) -> Option<u8> { it.next() }` with `I` a
`Copied<slice::Iter<u8>>`, proven by a differential test against native Rust.

## Plan

Found while testing `&mut &mut I` on 2026-10-29: the translation is `return it.next();`,
the protocol's item or `rt.DONE` rather than the `Option` the signature declares, so `tsc`
refuses it. A `next` read into a local first, as `it.next().unwrap_or(0)`, converts.

Public API: the translator's output.
4 changes: 2 additions & 2 deletions quest/m3/ts-unsafe.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ none of its own `unsafe`.
([#222](https://github.com/moq-dev/rust2/pull/222)): the bytes keep their type, so
this reinterprets nothing. Those getters also need `<[u8]>::get` and `get_mut` of a
range, and each integer's `from_le_bytes` and `from_ne_bytes`, and `chunks_vectored`
needs `std::io::IoSlice`: 184 of moq-net's 197 refusals in `bytes`, the rest being 12
of [`f32`](/quest/m3/ts-f32.md) and one of [`&mut &[u8]`](/quest/m3/ts-mut-ref.md).
needs `std::io::IoSlice`: 184 of moq-net's 196 refusals in `bytes`, the rest being 12
of [`f32`](/quest/m3/ts-f32.md).

Public API: the translator's output.
10 changes: 6 additions & 4 deletions ts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ crate translation reaches is refused, and so are two versions of one crate it re
| `Result<T, E>` | `rt.Result<T, E>`: `{ ok: true, value }` or `{ ok: false, error }`; `rt.OK` or `rt.ERR` where the payload is `undefined`, as in `Ok(())` |
| `ControlFlow<B, C>` | `rt.Result<C, B>`, `Ok` to continue; what `?` branches on is the value it was applied to, but for a `Poll`'s `Pending` and `Ready(None)`, which continue as `Ok` of themselves |
| tuple, `[T; N]`, `&[T]`, `Vec<T>` | an array; for bytes, `Uint8Array` for `[u8; N]`, `rt.ByteSlice` for `&[u8]` and `&[u8; N]`, and `rt.ByteVec` for `Vec<u8>` |
| `&T`, `&mut T`, `Box<T>`, `Reverse<T>`, `NonZero<T>` | the value; a `&mut` to a value JS copies, such as a number, an `Option`, or a `String`, or to an `Arc` or a `Waker`, is an `rt.Place<T>` |
| `&T`, `&mut T`, `Box<T>`, `Reverse<T>`, `NonZero<T>` | the value; a `&mut` to a value JS copies, such as a number, an `Option`, a `String`, or a reference, or to an `Arc` or a `Waker`, is an `rt.Place<T>` |
| `*const T`, `*mut T`, `NonNull<T>` | what a `&mut T` is: the object, or an `rt.Place<T>` to a value JS copies and to a library type such as a `Vec` or an `Arc`; `rt.NULL` for null and `rt.DANGLING` for dangling. A write of a whole object copies into it one object deep, as an assignment through a `&mut` does, so a pointer to a part kept as an object, such as a field of a tuple or struct type, is refused wherever the crate may put another object there; a read copies what the crate writes into in place |
| `MaybeUninit<T>` | `T`: `undefined` until written, or an object whose parts kept as objects are there, holding `undefined` |
| `union` | an object of slots named by offset, `at0` and `at8`, each holding the field part kept there; fields must overlap in the same type, or in a non-null pointer and an `Option` of it |
Expand Down Expand Up @@ -342,9 +342,11 @@ of them:
`put_` of an integer or `f64`, `put_slice`, `put_bytes`, and `put`, whose panics are
`bytes`'. `put` of the crate's own `Buf` into a `Vec<u8>` reads it through its methods
as `bytes` does, and into a `BytesMut` is refused, as `bytes` picks those methods by its
capacity.
The rest of `bytes`, such as the provided methods of the crate's own `Buf` and the impls
forwarding through a `&mut` or a `Box`, translates from its MIR, refused where that is.
capacity. The provided `copy_to_bytes` of the crate's own `Buf`, whose `BytesMut` has
the capacity it asks for, reads it chunk by chunk through its methods.
The rest of `bytes`, such as the other provided methods of the crate's own `Buf` and the
impls forwarding through a `&mut` or a `Box`, translates from its MIR, refused where
that is.
- `rand::rng()` is an `rt.ThreadRng`, whose `random` of an integer or `bool` and
`random_range` of an integer range map to `rt/rand.ts`. Each value comes from
`crypto.getRandomValues`, uniform as `rand`'s are, though no seed reproduces them, as
Expand Down
Loading