Skip to content

Use of &str in FluentArgs #171

Closed
Closed
@JohnnyJayJay

Description

@JohnnyJayJay

As mentioned in #170 , I am currently writing Java bindings for this project.

There is another issue I encountered: the use of &str as a key type in FluentArgs makes insertion of strings from other scopes impossible without leaking memory.
For example, this is not possible, because param is dropped:

fn put(args: &mut FluentArgs, param: String, value: FluentValue) {
    args.insert(&param, value);
}

This results in the fact that you can essentially only use literals as arguments for that method, unless you leak memory to make a &'static str.

My suggestion would be to use a different key type, such as Cow<str> or String. This would certainly be quite a breaking change, so I'm open to ideas how to fix this on the spot.

This issue may not only be relevant for my specific use case, I think.

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