-
Notifications
You must be signed in to change notification settings - Fork 37
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
Stop allocating so much while formatting. #100
Conversation
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.
Nice work, but still I found some nitpicks.
@@ -173,3 +184,21 @@ pub enum FormatText { | |||
pub struct FormatUnit { | |||
pub text: FormatText, | |||
} | |||
|
|||
|
|||
#[doc(hidden)] |
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.
Not necessary if the entire mod is not public, no?
|
||
} | ||
|
||
pub fn display_with<'a>(format: &'a Format, |
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.
Ideally this would be a method on Format
, but I realize that this is not possible due to the wish to constrain the public API.
You could also think about it as a constructor of FormatDisplay
but I'm not sure if that's an internal API we want.
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.
I turned it into a method of a private trait. I'm not entirely sure that the trait is appropriately generic, but given that it currently has a single use, I don't think that is a big deal.
Method => fmt.write_fmt(format_args!("{}", req.method)), | ||
URI => fmt.write_fmt(format_args!("{}", req.url)), | ||
Status => match res.status { | ||
Some(status) => fmt.write_fmt(format_args!("{}", status)), |
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.
You can replace this with status.fmt
I think. Same goes for similar branches.
Updated. |
Thanks! |
Oh, feel free to add yourself to the authors array in Cargo.toml though I'm not sure if that's how we're tracking contributors now. Otherwise I'll release a new version ASAP |
See #41.
This is a breaking change, as it cleans up the public API by hiding the details of formatting.