string_to_offset

Function string_to_offset 

Source
pub fn string_to_offset(s: &str) -> Result<usize>
Expand description

Parse a hexadecimal string to a numeric offset.

Accepts strings with or without “0x” prefix.

§Arguments

  • s - String containing hexadecimal number (e.g., “0x123456” or “123456”)

§Returns

Ok(usize) containing the parsed offset. Err(SubstrateError::ParseError) if parsing fails.

§Examples

use substrate::utils::string_to_offset;

let offset = string_to_offset("0x123456").expect("Parse failed");
assert_eq!(offset, 0x123456);