FFORGE//RS
← Roadmap

rust / LEVEL 3

The error string nobody can branch on

EST.35 MIN
01

THEORY / RETRIEVAL

What to restore

  • Separate invalid syntax from domain-range failures
  • Implement Display and Error without losing machine-readable variants

Errors serve callers and operators

A typed enum lets callers handle expected categories without parsing human text. `Display` remains an operator-facing description, while `std::error::Error` enables generic boundaries and optional source chaining.

Do not erase context too early

Converting every failure to `String` or `Box<dyn Error>` at a low layer removes exhaustiveness and stable branching. Erasure is useful at application boundaries, after domain code has preserved the distinctions it owns.

CHECKPOINT

Why can `PortError` be passed as `&dyn std::error::Error` after implementing the trait?

ISOLATED RUST 1.96
src/lib.rsEDIT

02 / IMPLEMENTATION

Implement the contract

Implement the typed port parser and its stable Display messages. Empty input, invalid decimal syntax, and values outside 1..=65535 must stay distinct.

Initializing editor…
CLOUD SANDBOXnetwork off · 256 MB · 12 s
1 / 64 KB
OUTPUT
Runner is waiting for a submission.