Rust

parse & FromStr

Në shqip përdoret i njëjti emër.

ShpjegimiSQ

"42".parse::<i32>() e kthen tekstin në numër dhe jep Result — Ok(42) ose Err po teksti s'është numër. Çdo tip që implementon FromStr mund të lexohet kështu.

EnglishEN

"42".parse::<i32>() turns text into a number and gives a Result — Ok(42), or Err if the text isn't a number. Any type implementing FromStr can be read this way.

Si ta mendosh

Si një përkthyes që të thotë kur s'e kupton fjalën.

Lexoje në anglisht

Like a translator who tells you when they don't understand a word.

Shembull kodirust

match "4x".parse::<i32>() {
    Ok(n) => println!("Numri: {n}"),
    Err(e) => println!("Gabim: {e}"),
}

Terma të lidhur