自己整一个:

use std::io::{self,*};
use std::str::FromStr;

fn main(){
    let stdin = io::stdin();
    for line in stdin.lock().lines(){
        let l = line.unwrap();
        let v = Vec::from(l.as_str().to_uppercase());
        let mut sum = 0i32;
        let mut weight = 0u32;
        for i in (0..v.len()).rev(){
            let y = char::from(v[i]);
            if 'X' == y {
                break;
            }
            let bit :i32 = match y {
                '0' => 0,
                '1' => 1,
                '2' => 2,
                '3' => 3,
                '4' => 4,
                '5' => 5,
                '6' => 6,
                '7' => 7,
                '8' => 8,
                '9' => 9,
                'A' => 10,
                'B' => 11,
                'C' => 12,
                'D' => 13,
                'E' => 14,
                'F' => 15,
                _ => -1,
            };
            sum += 16_i32.pow(weight) * bit;
            weight += 1;
        }
        println!("{}",sum);
    }
}