Repository navigation
feat(ts): translate the rest of a guard's methods - #392
Conversation
Quest-Claim: 51b7f77f4c2ce1db
Debug and Display of every guard write what it lends. MutexGuard::map and filter_map make an rt.MutexMap, a place of its part holding the mutex locked until it drops. Ref::try_map and RefMut::try_map reuse the guard maps, giving the guard back beside its error. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s::tries Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
|
On wasm32, locking a (written by Claude Opus 5.5) |
|
quest land removed this pull request from the queue: Conflicts with the base: ts/fixtures/lang/caller.ts, ts/fixtures/lang/expected/harness.ts, ts/fixtures/lang/src/harness.rs |
Problem
rust2-ts still refused part of std's guard API after #384:
DebugandDisplayof every guard (Ref,RefMut,MutexGuard, theRwLockguards, mapped or not),MutexGuard::mapandfilter_mapwith theMappedMutexGuardthey make, and the unstableRef::try_mapandRefMut::try_map.Approach
DebugorDisplay, as std's impls do, throughrt.fmt*with the caller's options. A field of a tuple element (value[0].value) is nowpureinfmt.rs, soDebugof a tuple holding a guard needs no statements.Result::unwrapof atry_maphits that case.MappedMutexGuardisStd::MutexGuard, so its deref, drop, and type lower as aMutexGuard's do. A map makes anrt.MutexMap, aMappedof where its part is that forwardslockedto the guard it took over.mutexUnlockstays one property write with noinstanceof.RefMapandMutexMapshare theMappedbase for reading and writing through a place.guard_map.Okholds a guard of the part, at its place where an exclusive guard needs one.Errgives the guard back beside the error, as the tuple[guard, error].borrows::tries,locks::mutex_mapped, andlocks::printed. They cover writes through mapped guards, parts JS copies and parts it doesn't, whole writes, an error that drops, release when the last guard drops, and{:?},{:#?}, and paddedDisplay. Mutex lock state is checked throughtry_lock, since locking twice aborts on wasm32 (questts-abort-differential).Impact
rt.MutexMap,rt.mutexMap,rt.mutexFilterMap,rt.refTryMap, andrt.refMutTryMapare new runtime exports. No config or CLI change. Nothing breaks, so noMIGRATE.mdentry.Alternatives
rt.Mutexanrt.RefCellsoRefMapcovers both. I rejected this because the two fail differently on conflict (a mutex's relock message, a cell's borrow counts), and everyMutexwould then pay for borrow counting.instanceofon unlock, asrefCellOfdoes for cells. I rejected this to keep the unlock of a plainMutexGuarda single write.Follow-ups
Review
mechanical fix by codex / Codex:
Merged base, preserving both guard and capacity test cases in three conflicts; regenerated harness snapshot. Passed in ts/ with pinned nightly: UPDATE_EXPECT=1 cargo test --locked -p rust2-ts --test fixtures lang -- --exact; cargo test --locked -p lang-fixture; cargo test --locked -p rust2-ts --bin rust2-ts --test runtime; cargo clippy --locked -p rust2-ts --all-targets -- -D warnings; cargo fmt --all --check; tsc -p runtime. All 365 language snapshots match generated output.(head 11870f9)quest review --base origin/main.ts/fixtures/lang/src/borrows.rs:572: a cell's shared guard was still alive when its exclusive guard was borrowed, so the printing branch ofborrows::triesalways panicked. Fixed: the two guards now print in separate statements.🤖 Generated with Claude Code