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

Expose the format function of DelayedFormat #1649

Closed
tugtugtug opened this issue Jan 16, 2025 · 3 comments
Closed

Expose the format function of DelayedFormat #1649

tugtugtug opened this issue Jan 16, 2025 · 3 comments

Comments

@tugtugtug
Copy link

It seems there is no way to format into a pre-allocated buffer with DelayedFormat, while this seems a regular enough use case. Can the format function of DelayedFormat be exposed?

@djc
Copy link
Member

djc commented Jan 16, 2025

Hmm, feels like that would be a pretty idiosyncratic API. What are you actually trying to achieve?

@tugtugtug
Copy link
Author

@djc, the biggest use case for me is in the formatting of strings that include a timestamp. For example, a log header that will always contain a timestamp. This operation is frequent and can be made to write to the same log buffer. Basically, it is more efficient in this case to avoid an allocation of a String. In the crate time, it supports a method write_into, which does exactly that.

@djc
Copy link
Member

djc commented Jan 20, 2025

Alright, feel free to send a PR.

tugtugtug pushed a commit to tugtugtug/chrono that referenced this issue Jan 21, 2025
Request for chronotope#1649
- renamed format to format_into and made it public.
- added format_into_io to allow format into a `std::io::Write`.
- added unittests
- added benchmarks for the 3 methods, `Display`, `format_into`, and
  `format_into_io`.
tugtugtug pushed a commit to tugtugtug/chrono that referenced this issue Jan 21, 2025
Request for chronotope#1649
- renamed format to format_into and made it public.
- added format_into_io to allow format into a `std::io::Write`.
- added unittests
- added benchmarks for the 3 methods, `Display`, `format_into`, and
  `format_into_io`.
tugtugtug pushed a commit to tugtugtug/chrono that referenced this issue Jan 21, 2025
Request for chronotope#1649
- renamed format to format_into and made it public.
- added format_into_io to allow format into a `std::io::Write`.
- added unittests
- added benchmarks for the 3 methods, `Display`, `format_into`, and
  `format_into_io`.
tugtugtug pushed a commit to tugtugtug/chrono that referenced this issue Jan 21, 2025
Request for chronotope#1649
- renamed format to format_into and made it public.
- added format_into_io to allow format into a `std::io::Write`.
- added unittests
- added benchmarks for the 3 methods, `Display`, `format_into`, and
  `format_into_io`.
tugtugtug pushed a commit to tugtugtug/chrono that referenced this issue Jan 21, 2025
Request for chronotope#1649
- renamed format to format_into and made it public.
- added format_into_io to allow format into a `std::io::Write`.
- added unittests
- added benchmarks for the 3 methods, `Display`, `format_into`, and
  `format_into_io`.
tugtugtug pushed a commit to tugtugtug/chrono that referenced this issue Jan 22, 2025
Request for chronotope#1649
- renamed format to write-to and made it public.
- added unittests
- added benchmarks to compare and show  `Display` is slower than `write_to` in that
  specific use case.
tugtugtug pushed a commit to tugtugtug/chrono that referenced this issue Jan 22, 2025
Request for chronotope#1649
- renamed format to write-to and made it public.
- added unittests
- added benchmarks to compare and show  `Display` is slower than `write_to` in that
  specific use case.
tugtugtug pushed a commit to tugtugtug/chrono that referenced this issue Jan 22, 2025
Request for chronotope#1649
- renamed format to write-to and made it public.
- added unittests
- added benchmarks to compare and show  `Display` is slower than `write_to` in that
  specific use case.
tugtugtug pushed a commit to tugtugtug/chrono that referenced this issue Jan 22, 2025
Request for chronotope#1649
- renamed format to write-to and made it public.
- added unittests
- added benchmarks to compare and show  `Display` is slower than `write_to` in that
  specific use case.
tugtugtug pushed a commit to tugtugtug/chrono that referenced this issue Jan 23, 2025
Request for chronotope#1649
- renamed format to write-to and made it public.
- added unittests
- added benchmarks to compare and show  `Display` is slower than `write_to` in that
  specific use case.
djc pushed a commit that referenced this issue Jan 23, 2025
Request for #1649
- renamed format to write-to and made it public.
- added unittests
- added benchmarks to compare and show  `Display` is slower than `write_to` in that
  specific use case.
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

No branches or pull requests

2 participants