MCPcopy Create free account
hub / github.com/endbasic/endbasic / resolve_string

Method resolve_string

core/src/mem.rs:313–328  ·  view source on GitHub ↗

Resolves this pointer and returns the string it points to. Panics if the pointed-to datum is not a `Text` value.

(
        &self,
        constants: &'b [ConstantDatum],
        heap: &'b Heap,
    )

Source from the content-addressed store, hash-verified

311 ///
312 /// Panics if the pointed-to datum is not a `Text` value.
313 pub(crate) fn resolve_string<'b>(
314 &self,
315 constants: &'b [ConstantDatum],
316 heap: &'b Heap,
317 ) -> &'b str {
318 match self {
319 DatumPtr::Constant(index) => match &constants[unchecked_u24_as_usize(*index)] {
320 ConstantDatum::Text(s) => s,
321 _ => panic!("Constant pointer does not point to a Text value"),
322 },
323 DatumPtr::Heap(index) => match heap.get(unchecked_u24_as_usize(*index)) {
324 HeapDatum::Text(s) => s,
325 _ => panic!("Heap pointer does not point to a Text value"),
326 },
327 }
328 }
329
330 /// Extracts the heap index from this pointer.
331 ///

Callers 4

from_rawMethod · 0.80
deref_stringFunction · 0.80
get_stringMethod · 0.80
deref_stringMethod · 0.80

Calls 1

getMethod · 0.45

Tested by

no test coverage detected