Skip to content

refactor(dag): ExportFormat implements FromStr instead of shadowing it - #148

Merged
ApiliumDevTeam merged 1 commit into
fix/nan-in-clamp-shaped-expressionsfrom
refactor/exportformat-implements-fromstr
Jul 30, 2026
Merged

refactor(dag): ExportFormat implements FromStr instead of shadowing it#148
ApiliumDevTeam merged 1 commit into
fix/nan-in-clamp-shaped-expressionsfrom
refactor/exportformat-implements-fromstr

Conversation

@ApiliumDevTeam

Copy link
Copy Markdown
Contributor

Last of the stack. Base is #147. Touches a public signature, which is why it is separate.

What was wrong

ExportFormat::from_str was an inherent method returning Option. It shadows std::str::FromStr::from_str and returns a different shape from it, so a caller reading ExportFormat::from_str(..) could not tell which one they were getting — and got no reason for the failure either way.

What it is now

A real FromStr with an error that carries the offending input and knows the accepted spellings.

That last part fixed a live inconsistency: the list of valid formats lived in the REST handler, where it could drift from the parser with nothing to catch it. It already had. The handler advertised "dot, mermaid, json" while the parser also accepted graphviz and md. The type owns the list now, and a test asserts the message names every spelling the parser takes.

Blast radius

One caller outside this module's own tests, migrated here. Technically a public-API change, so worth a minor version even though every consumer is in this workspace.

Verification

#[allow(clippy::should_implement_trait)] removed — no #[allow] from this series is left anywhere.

cargo clippy --workspace --all-targets -- -D warnings exit 0 · cargo fmt --all --check exit 0 · 2248 tests green.

@ApiliumDevTeam
ApiliumDevTeam force-pushed the fix/nan-in-clamp-shaped-expressions branch from 30aaba4 to 9b62d8d Compare July 29, 2026 10:06
@ApiliumDevTeam
ApiliumDevTeam force-pushed the refactor/exportformat-implements-fromstr branch from 1f61a38 to d8e5c58 Compare July 29, 2026 10:06
`ExportFormat::from_str` was an inherent method returning `Option`, which
shadows `std::str::FromStr::from_str` and returns a different shape from
it. A caller reading `ExportFormat::from_str(..)` could not tell which one
they were getting, and got no reason for the failure either way.

Implement the trait with an error that carries the offending input and
knows the accepted spellings. The list of valid formats lived in the REST
handler, where it could drift away from the parser with nothing to catch
it — it already advertised "dot, mermaid, json" while the parser also
accepted "graphviz" and "md". Now the type owns it and a test asserts the
message names every spelling the parser takes.

One caller migrated. `cargo clippy --workspace --all-targets -- -D
warnings` and `cargo fmt --all --check` are both clean with no `#[allow]`
left anywhere from this series.
@ApiliumDevTeam
ApiliumDevTeam force-pushed the fix/nan-in-clamp-shaped-expressions branch from 9b62d8d to 98fa442 Compare July 29, 2026 10:25
@ApiliumDevTeam
ApiliumDevTeam force-pushed the refactor/exportformat-implements-fromstr branch from d8e5c58 to 1ca5a92 Compare July 29, 2026 10:25
@ApiliumDevTeam
ApiliumDevTeam merged commit e4a8ee4 into fix/nan-in-clamp-shaped-expressions Jul 30, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant