expression

Persian decimal digits — explicit parsing policy

A local numeric field can accept Persian digits through explicit conversion before parsing. This example does not accept Arabic-Indic digits or punctuation; define those separately if needed. Expected stdout (not executed): 42 Common mistake: Treating every Unicode numeric symbol as a decimal digit.

Formal Syntax & Structure

rust syntaxrust
map U+06F0..=U+06F9 to ASCII digits

Working Example

Example Snippetrust
fn main() {    let digits = "۴۲";    let ascii: String = digits.chars().map(|c| match c { '\u{06F0}'..='\u{06F9}' => char::from_u32(c as u32 - 0x06F0 + 0x30).unwrap(), other => other }).collect();    println!("{}", ascii.parse::<u32>().unwrap());}
Rust Reference