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

format::Item documentation and ownership #1183

Closed
pitdicker opened this issue Jul 11, 2023 · 3 comments
Closed

format::Item documentation and ownership #1183

pitdicker opened this issue Jul 11, 2023 · 3 comments

Comments

@pitdicker
Copy link
Collaborator

From #852 (review):

@bruceg, please let us know if there are any documentation improvements needed in the format::Item and format::StrftimeItems API

This feedback seems useful to open an issue for #852 (comment):

A good example of how it can be used would be useful for documentation, ie feeding it in to format_with_items or what have you.

A bigger issue we had with this type was ownership. When parsing a string, we get items that reference the same lifetime as the string. When we later want to collect those items into a vec and store it for repeated use, we had to convert those into Item<'static> by boxing all the Literals and Spaces into OwnedLiteral and OwnedSpace. A better interface, that mimics other Rust types, might be to drop the owned variants from Item, but have a fn to_owned(&self) -> OwnedItem which has all boxed variants. I haven't looked at the underlying code to see if this makes sense for all your uses, though.

@pitdicker
Copy link
Collaborator Author

I have a commit that adds this as part of the experiments around a new formatting API.

@pitdicker
Copy link
Collaborator Author

Included in #1184.

@pitdicker
Copy link
Collaborator Author

Fixed in #1184.

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

1 participant