Borrow typed heap payloads with Value::get_as
Summary
value.get_as::<T>(heap) borrows a payload directly from the heap. For example, list indexing can use if let Some(slice) = key.get_as::<Slice>(vm.heap) to read the slice bounds. The result is tied to the heap borrow, and the lookup uses the existing Heap::get without creating a reader guard.
This extracts the borrowed accessor from #1024 on top of #1421. The payload registry supplies the match for inline and boxed payloads. With the current untagged references, immediate values return None before a heap lookup, and heap references need one lookup to check their payload type. The caller migrations cover single-type reads. Multi-type dispatch can continue matching several variants on a single heap lookup.
Tests
Added a unit test that borrows bytes stored inline in a heap slot and a boxed named tuple. It also checks a mismatched heap payload and an immediate value. Ran the Monty tests and interpreter fixtures with memory-model-checks, the workspace Rust lints, formatting, and the 32-bit WASI build check.
Summary by cubic
Adds Value::get_as::<T>(heap) to borrow a typed heap payload directly, while Value absorbs borrowed accessors for bytes, strings, and long ints so call sites no longer match Value::Ref against HeapData variants by hand.
get_asreuses the existingHeap::getlookup via the payload registry's newfrom_heap_data, checking the payload type for heap references and returningNonefor immediate values.Value::as_bytes,as_str,as_long_int, andtry_as_str(renamed fromtry_to_str) replace local helpers likevalue_as_bytes,str_of,buffer, and theis_long_int/long_intwrappers; codec inputs now borrow byte slices directly instead of copying throughvalue_to_owned_bytes.- base16 and base32 decoders fold ASCII case and translate digits while decoding, so
casefold=Trueaccepts mixed-case input; altchars translate before strict padding checks, and invalid digits take precedence over odd-length errors. - Ascii85 decoding with a custom
ignorecharsnow charges the session for the input copy it makes during decoding. - base64 encoders now raise the standard bytes-like
TypeError; CPython prefixes that message withmemoryview:forb32encode,b32hexencode,b85encode,z85encodeanda85encode. - Unit tests cover inline and boxed payloads, mismatched heap payloads, immediate values, and interned versus heap-allocated bytes.