Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow printing of @enum values to TOML as Strings #233

Closed
wants to merge 1 commit into from

Conversation

johnomotani
Copy link
Collaborator

Adds a method of TOML.Internals.Printer.to_toml_value that handles Enum values, allowing Enums to be printed to TOML format strings or files.

Counterpart to the get(d::Dict, key, default::Enum) that lets us read Enums from Dicts, which means we can read them from TOML files by supplying a value of the Enum as the default.

Slightly hacky because TOML.Internals.Printer.to_toml_value appears to be an internal method, not part of the public API, but TOML.jl does not change very much, so in practice this should be fine.

@johnomotani johnomotani added the enhancement New feature or request label Aug 2, 2024
@johnomotani
Copy link
Collaborator Author

On second thoughts, this is a bad solution. Modifying TOML.Internals.Printer.to_toml_value() means that we would change the behaviour of TOML.print() (i.e. how it handles Enum) as a side effect whenever moment_kinetics is loaded. I think a better solution is to have our own function for writing to TOML - see upcoming PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant