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.
- [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
- [Checks on the differential harnesses](/quest/m3/ts-harness.md) - step lists that drift, literal op bytes, and `refs`'s coverage fail a test or get cases
- [Ordering in std](/quest/m3/ts-ordering.md) - `cmp::max`/`min`, `is_sorted`, and `BinaryHeap`, and #173's cost on integers measured
- [Arc's unique-access functions](/quest/m3/ts-arc-mut.md) - `Arc::get_mut`, `make_mut`, `pin`, and `as_deref` of an `Option<Arc>` translate
- [Debug and Display of Arc and ranges](/quest/m3/ts-fmt-wrappers.md) - `Arc<T>` formats as `T`, and ranges as std's `Debug`
- [Fold a match a bool decided](/quest/m3/ts-fold-bool.md) - `if matches!` and derived `==` drop a later match's dead arms
- [Rename one instance](/quest/m3/ffi-instance-rename.md) - `rename` by an instance's path, once a consumer's clash needs it
Expand Down
14 changes: 0 additions & 14 deletions quest/m3/ts-arc-mut.md

This file was deleted.

2 changes: 1 addition & 1 deletion ts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ crate translation reaches is refused, and so are two versions of one crate it re
| constant | its value, inlined as Rust inlines it |
| a type that drops | a class with `[Symbol.dispose]`: its `Drop` impl, then its fields |
| a type's function | a function of the type's module, taking `self` first: `Decoder.slice(dec, 4)` after `import * as Decoder` |
| `Arc<T>`, `Rc<T>`, `Weak<T>`, `Mutex<T>` | `rt.Arc` for either, with its strong and weak counts, and `new_cyclic`'s `Weak` upgrading only once its value is made; `rt.Weak`, counted in its `rt.Arc` until it drops, and of no `Arc` once made by `Weak::new`; `rt.Mutex`, its own guard, which a lock gives as `Ok` and the guard's drop unlocks: locking it again while held panics and `try_lock` gives `WouldBlock`, as wasm32's do, and a panic aborts, so nothing poisons it and `thread::panicking` is `false` |
| `Arc<T>`, `Rc<T>`, `Weak<T>`, `Mutex<T>` | `rt.Arc` for either, with its strong and weak counts, and `new_cyclic`'s `Weak` upgrading only once its value is made, `get_mut` lending its value only while no other `Arc` or `Weak` shares it, and `make_mut` cloning it into a new `rt.Arc` while another `Arc` shares it, or moving it there while only `Weak`s do, which then dangle; `rt.Weak`, counted in its `rt.Arc` until it drops, and of no `Arc` once made by `Weak::new`; `rt.Mutex`, its own guard, which a lock gives as `Ok` and the guard's drop unlocks: locking it again while held panics and `try_lock` gives `WouldBlock`, as wasm32's do, and a panic aborts, so nothing poisons it and `thread::panicking` is `false` |
| `PoisonError<T>`, `TryLockError<T>` | the `T` it holds; `rt.TryLockError<T>`, tagged as `Bound` is |
| `Cell<T>`, `RefCell<T>`, `RwLock<T>` | `rt.Cell`, the place holding its value in `v`; `rt.RefCell` for either of the others, its own guard, counting its borrows: borrowing it while that conflicts panics as `RefCell`'s does, and locking it so aborts as wasm32's `RwLock` does |
| `thread_local!`, `LocalKey<T>` | an `rt.LocalKey`, a module's value, which makes its value on first use from the `const` or the expression and never drops it, as wasm32's do; `with` calls its function on that value, `try_with` never fails, the `Cell` and `RefCell` helpers lower from std, and a `RefCell` key's `set` and `with_borrow_mut` borrow it as `borrow_mut` does |
Expand Down
40 changes: 40 additions & 0 deletions ts/fixtures/lang/expected/core/option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,34 @@ export function map$Option_Arc_Made_u64_get_closure0(self: rt.Arc<Made.Made> | u
return f(self);
}

export function map$Option_Arc_Noisy_Arc_Noisy_clone(self: rt.Arc<counts_Noisy.Noisy> | undefined, _: (a0: rt.Arc<counts_Noisy.Noisy>) => rt.Arc<counts_Noisy.Noisy>): rt.Arc<counts_Noisy.Noisy> | undefined {
if (self === undefined) {
return undefined;
}
return rt.arcClone(self);
}

export function map$Option_Arc_Noisy_Noisy_deref(self: rt.Arc<counts_Noisy.Noisy> | undefined, _: (a0: rt.Arc<counts_Noisy.Noisy>) => counts_Noisy.Noisy): counts_Noisy.Noisy | undefined {
if (self === undefined) {
return undefined;
}
return self.value;
}

export function map$Option_Arc_dyn_Shape_u32_shared_closure0(self: rt.Arc<Shape.Shape> | undefined, f: (a0: rt.Arc<Shape.Shape>) => rt.u32): rt.u32 | undefined {
if (self === undefined) {
return undefined;
}
return f(self);
}

export function map$Option_Arc_u8_u8_deref(self: rt.Arc<rt.u8> | undefined, _: (a0: rt.Arc<rt.u8>) => rt.u8): rt.u8 | undefined {
if (self === undefined) {
return undefined;
}
return self.value;
}

export function map$Option_Box_Named_u16_edits_closure31(self: Named.Named | undefined, f: (a0: Named.Named) => rt.u16): rt.u16 | undefined {
if (self === undefined) {
return undefined;
Expand Down Expand Up @@ -377,6 +398,13 @@ export function mapOr$Option_Nibble_u8_sets_closure4(self: Nibble.Nibble | undef
return f(self);
}

export function mapOr$Option_Noisy_u8_arcs_closure2(self: counts_Noisy.Noisy | undefined, default_: rt.u8, f: (a0: counts_Noisy.Noisy) => rt.u8): rt.u8 {
if (self === undefined) {
return default_;
}
return f(self);
}

export function mapOr$Option_Noisy_u8_borrows_closure0(self: Noisy.Noisy | undefined, default_: rt.u8, f: (a0: Noisy.Noisy) => rt.u8): rt.u8 {
if (self === undefined) {
return default_;
Expand Down Expand Up @@ -692,6 +720,18 @@ export function okOrElse$Option_u8_u16_options_closure12(self: rt.u8 | undefined
return rt.Ok(self);
}

export function asDeref$Option_Arc_Noisy(self: rt.Arc<counts_Noisy.Noisy> | undefined): counts_Noisy.Noisy | undefined {
return map$Option_Arc_Noisy_Noisy_deref(self, (a0: rt.Arc<counts_Noisy.Noisy>): counts_Noisy.Noisy => {
return a0.value;
});
}

export function asDeref$Option_Arc_u8(self: rt.Arc<rt.u8> | undefined): rt.u8 | undefined {
return map$Option_Arc_u8_u8_deref(self, (a0: rt.Arc<rt.u8>): rt.u8 => {
return a0.value;
});
}

export function and$Option_u8_u8(self: rt.u8 | undefined, optb: rt.u8 | undefined): rt.u8 | undefined {
if (self === undefined) {
return undefined;
Expand Down
41 changes: 41 additions & 0 deletions ts/fixtures/lang/expected/counts.ArcReleasing.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Generated by rust2-ts. Do not edit.

import * as rt from "./rt.ts";
import { drop$RefCell_Vec_Arc_ArcReleasing } from "./lib.ts";

/**
* Releases the other handles to it when cloned, as its id says it was, and logs its
* id when it drops.
*/
export class ArcReleasing {
id: rt.u8;
others: rt.Arc<rt.RefCell<rt.Arc<ArcReleasing>[]>>;
log: rt.Arc<rt.RefCell<rt.ByteVec>>;

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

[Symbol.dispose](): void {
drop$Drop(this);
rt.arcDrop(this.others, drop$RefCell_Vec_Arc_ArcReleasing);
this.log[Symbol.dispose]();
}
}

export function clone$Clone(self: ArcReleasing): ArcReleasing {
const _5: rt.RefCell<rt.Arc<ArcReleasing>[]> = rt.refCellBorrowMut(self.others.value);
rt.vecTruncate(_5.value, 0, rt.drop);
rt.refMutRelease(_5);
return new ArcReleasing(rt.u8WrappingAdd(self.id, 1), rt.arcClone(self.others), rt.arcClone(self.log));
}

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

//# sourceMappingURL=counts.ArcReleasing.ts.map
4 changes: 4 additions & 0 deletions ts/fixtures/lang/expected/counts.Noisy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ export class Noisy {
}
}

export function clone$Clone(self: Noisy): Noisy {
return new Noisy(rt.u8WrappingAdd(self.id, 1), rt.arcClone(self.log));
}

export function drop$Drop(self: Noisy): void {
const _5: rt.Mutex<rt.ByteVec> = rt.mutexLock(self.log.value);
rt.byteVecPush(_5.value, self.id);
Expand Down
41 changes: 41 additions & 0 deletions ts/fixtures/lang/expected/counts.RcReleasing.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Generated by rust2-ts. Do not edit.

import * as rt from "./rt.ts";
import { drop$RefCell_Vec_Rc_RcReleasing } from "./lib.ts";

/**
* Releases the other handles to it when cloned, as its id says it was, and logs its
* id when it drops.
*/
export class RcReleasing {
id: rt.u8;
others: rt.Arc<rt.RefCell<rt.Arc<RcReleasing>[]>>;
log: rt.Arc<rt.RefCell<rt.ByteVec>>;

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

[Symbol.dispose](): void {
drop$Drop(this);
rt.arcDrop(this.others, drop$RefCell_Vec_Rc_RcReleasing);
this.log[Symbol.dispose]();
}
}

export function clone$Clone(self: RcReleasing): RcReleasing {
const _5: rt.RefCell<rt.Arc<RcReleasing>[]> = rt.refCellBorrowMut(self.others.value);
rt.vecTruncate(_5.value, 0, rt.drop);
rt.refMutRelease(_5);
return new RcReleasing(rt.u8WrappingAdd(self.id, 1), rt.arcClone(self.others), rt.arcClone(self.log));
}

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

//# sourceMappingURL=counts.RcReleasing.ts.map
Loading