projectfluent / fluent-rs

Rust implementation of Project Fluent
https://projectfluent.org
Apache License 2.0
1.08k stars 97 forks source link

Add FluentValue::Custom #153

Closed zbraniecki closed 4 years ago

zbraniecki commented 4 years ago

Implements #146.

This is an implementation based on the dynamic dispatch approach suggested by @Manishearth .

There's an alternative approach using partial suggested by Lina - https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=ad520cb4f7ece7a41e01a9079bdf7901

I like it more, but unfortunately it turns FluentValue into a generic and requires a pretty painful conversion of the whole codebase to FluentValue<A> in tons of places.

@Manishearth - lmk what you think, and if you prefer the generic partial approach I can go refactor the code for it.

Manishearth commented 4 years ago

There's an alternative approach using partial suggested by Lina - https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=ad520cb4f7ece7a41e01a9079bdf7901

If you're boxing the Custom one anyway there's not much additional benefit to doing that over dynamic dispatch, dynamic dispatch isn't much more expensive if you're boxing anyway.