MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / from_str

Method from_str

cranelift/codegen/src/ir/instructions.rs:332–341  ·  view source on GitHub ↗

Parse an Opcode name from a string.

(s: &str)

Source from the content-addressed store, hash-verified

330
331 /// Parse an Opcode name from a string.
332 fn from_str(s: &str) -> Result<Self, &'static str> {
333 use crate::constant_hash::{probe, simple_hash};
334
335 match probe::<&str, [Option<Self>]>(&OPCODE_HASH_TABLE, s, simple_hash(s)) {
336 Err(_) => Err("Unknown opcode"),
337 // We unwrap here because probe() should have ensured that the entry
338 // at this index is not None.
339 Ok(i) => Ok(OPCODE_HASH_TABLE[i].unwrap()),
340 }
341 }
342}
343
344impl<'a> Table<&'a str> for [Option<Opcode>] {

Callers

nothing calls this directly

Calls 3

simple_hashFunction · 0.85
OkFunction · 0.85
unwrapMethod · 0.45

Tested by

no test coverage detected