Skip to content

Owned variants of APIs where &str is used #200

Open
@abnormalmaps

Description

@abnormalmaps

I've been using this crate for personal project of mine, and I've sometimes found myself wanting to do something like this this:

fn make_message(token: &Token) -> Message<'_> {
    Level::Error.header(format!("unhandled token `{}`", token.src))
        .[...]
}

For obvious reasons, this doesn't directly work. To make it work the error string has to be stored out of line elsewhere, but this isn't always convenient (at least, it isn't for my design). It would be easier if there was a variant of (at least some) of the APIs which accepts a String instead, and the fields internally store a Cow<'src, 'str> instead of a &'src str.

Incidentally, this also might help people who have use cases that would have wanted #101, since it would be easier to directly format into a String that is stored by the Message.

Metadata

Metadata

Assignees

No one assigned

    Labels

    M-breaking-changeMeta: Implementing or merging this will introduce a breaking change

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions