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

Change Writeable::writeable_to_string to return a Cow #1452

Merged
merged 4 commits into from
Dec 30, 2021

Conversation

sffc
Copy link
Member

@sffc sffc commented Dec 30, 2021

Also adds impl Writeable for str.

This enables writeable_to_string to be more efficient in certain cases.

Replaces part of #1438

Copy link
Member

@Manishearth Manishearth left a comment

Choose a reason for hiding this comment

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

I kinda feel like this is a method you're only going to call when you need something owned, but I guess this is fine.

@sffc
Copy link
Member Author

sffc commented Dec 30, 2021

I kinda feel like this is a method you're only going to call when you need something owned, but I guess this is fine.

The use case is in #1438. We need to look at the string the Writeable is going to append to the sink in order to modify the behavior in some way (such as switching between "y" and "e" in Spanish). It's nice to avoid the allocation.

@Manishearth
Copy link
Member

Yeah I noticed, which is why I approved this, I just find it a little weird.

@sffc sffc merged commit 59edff5 into unicode-org:main Dec 30, 2021
@sffc sffc deleted the writeable-cow branch December 30, 2021 20:22
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.

None yet

3 participants