Parse an Opcode name from a string.
(s: &str)
| 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 | |
| 344 | impl<'a> Table<&'a str> for [Option<Opcode>] { |
nothing calls this directly
no test coverage detected