Skip to content

Conversation

@alchezar
Copy link

@alchezar alchezar commented Feb 1, 2026

Summary

Refactored the HTML to text conversion NIF to follow idiomatic Rust patterns and improve code maintainability.

Changes

  • Static atoms — replaced runtime Atom::from_str() calls with rustler::atoms! macro for better performance
  • Options struct — extracted configuration into a dedicated struct
  • Trait implementations — added TryFrom<Term> for parsing and From<Options> for conversion to html2text config
  • Macro for repetitive code — introduced set_if_ok! macro to reduce boilerplate in option parsing
  • Documentation — added doc comments for items

Benefits

  • Cleaner separation of concerns
  • Better readability and maintainability
  • Slightly improved performance (static atoms)
  • No functional changes — existing API remains the same

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