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

Add Writeable WithPart helper #5328

Merged
merged 1 commit into from
Aug 6, 2024
Merged

Conversation

sffc
Copy link
Member

@sffc sffc commented Aug 6, 2024

This is useful for interacting with nested formatters such as ListFormatter and Pattern that interpolate writeables. It allows setting custom parts on the interpolated writeables.

We could leave this up to userland, but I think it is better implemented as an adapter in the writeable create because

  1. It is a fairly common use case
  2. Our impl is correct and optimal: all functions are inline and bubble through except write_to_parts

@kartva Something like this might help.

CC @younies

@sffc sffc requested a review from robertbastian as a code owner August 6, 2024 05:46
}
}

impl<T: Writeable + ?Sized> fmt::Display for WithPart<T> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use the macro to implement this?

Copy link
Member Author

@sffc sffc Aug 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The macro doesn't support <T>. I've been wanting to maybe fix that, but it's not clear what would be the best syntax.

@sffc sffc merged commit cea2a8c into unicode-org:main Aug 6, 2024
28 checks passed
@sffc sffc deleted the writeable-with-part branch August 6, 2024 16:54
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.

2 participants