Skip to content

format::Item documentation and ownership #1183

@pitdicker

Description

@pitdicker

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions