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
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)),
}
}
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
| # | Typist | Acc | WPM |
|---|---|---|---|
| 1 | Yoftahe Abraham | 96.88% | 37 |