Closed XAMPPRocky closed 3 years ago
Hmm, I'm torn on this. I'm wondering if there's a way to handle both scenarios without having to give up on the former.
See #94 for the motivation for current design.
@zbraniecki AFAIK the best way to handle this would be Generic Associated Types but that isn't currently available. I don't know what the best workaround would be but with the current API I can actually be allocating more since I have to construct a new map with each key by reference and each value by value versus just allocating a string each time. If I wanted to reduce allocations with Fluent I could do that on the user side with memoization for the argument map but I actually can't use memoization on FluentArgs
currently because memoization requires owning the data in some way.
@XAMPPRocky can you check if the current master branch solved it? I switched FluentArgs
to accept Cow
which hopefully solves it.
Yeah Cow
works for me. Thanks for working on this!
Currently
FluentArgs
is aHashMap<&str, FluentValue>
, which is okay when you're using str literals as keys, however when you're constructing your map dynamically you don't have aHashMap<&str, V>
only aString
. Currently you have to construct a new HashMap that takes the key by reference and clones theFluentValue
. It would easier for users and more appropriate if it wasHashMap<String, FluentValue>
.