-
Notifications
You must be signed in to change notification settings - Fork 2
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
Consistify custom formatting with custom parsing and expose in the public API #54
Conversation
src/string_impls/to_string.rs
Outdated
/// bar: true | ||
/// }"#); | ||
/// ``` | ||
pub fn spaced(mut self) -> Self { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: indented
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mmm spaced isn't the best word for this is it! I was also thinking pretty
to align with eg serde_json's use of the word!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that would also be a good name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to pretty
; thanks for pointing this out!
This PR exposes two new functions for formatting values,
crate::stringify::to_writer
andcrate::stringify::to_writer_custom
(to align with the already presentcrate::stringify::from_str_custom
), and also exposes a newcrate::stringiy::custom_formatters
containing a formatter for displaying things as hex.to_writer_custom
exposes aToWriterBuilder
. This provides options for customising the output of a value, such as a compact mode or a spaced mode for pretty printing values, and options to configure the indentation of spaced values. A way to print the value context information is also exposed.Some of this logic was already added in #52, but now it is being extended and exposed for general usage.