rustintermediate

Rust Port Parser with Result

Robust configuration value parsing using Rust Result and match

By ApeType Staff·7 lines·261 characters·1,420 total attempts
SOURCE CODE·rust
pub fn parse_port(input: &str) -> Result<u16, String> { match input.trim().parse::<u16>() { Ok(port) if port > 1024 => Ok(port), Ok(_) => Err("Port must be unprivileged (> 1024)".to_string()), Err(e) => Err(format!("Invalid port integer: {}", e)), } }
UTF-8 · Tab indentationStandard Strict Parsing
TRANSCRIBE

Ready when you are.

Test your muscle memory and transcription speed against this exact snippet.

Start Typing
Tip: Press Esc anytime to restart

Best runs on this snippet

#TypistAccWPM
1Yoftahe Abraham96.88%37