projectfluent / fluent-rs

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

`FluentBundle::new` doesn't work in `0.9.1` with `fluent-langneg` peer dependency. #157

Closed XAMPPRocky closed 4 years ago

XAMPPRocky commented 4 years ago

Hello, currently this code doesn't compile with 0.9.1 it provides a trait bound error displayed below, because I'm using unic_langid 0.8 (which is required to use fluent-langneg), and fluent-bundle depends on 0.7. This is not present in the current master. If a patch release could be released, this would solve the problem.

Code

pub fn create_bundle(lang: LanguageIdentifier) -> FluentBundle<&'static FluentResource> {
    FluentBundle::new(&[lang])
}

Error

error[E0277]: the trait bound `unic_langid_impl::LanguageIdentifier: std::convert::From<unic_langid_impl::LanguageIdentifier>` is not satisfied
   --> src/loader.rs:239:61
    |
239 |     let mut bundle: FluentBundle<&'static FluentResource> = FluentBundle::new(&[lang]);
    |                                                             ^^^^^^^^^^^^^^^^^ the trait `std::convert::From<unic_langid_impl::LanguageIdentifier>` is not implemented for `unic_langid_impl::LanguageIdentifier`
    |
   ::: /Users/ep/.cargo/registry/src/github.com-1ecc6299db9ec823/fluent-bundle-0.9.1/src/bundle.rs:155:18
    |
155 |         locales: impl IntoIterator<Item = &'a L>,
    |                  ------------------------------- required by this bound in `fluent_bundle::FluentBundle::<R>::new`
    |
    = note: required because of the requirements on the impl of `std::convert::Into<unic_langid_impl::LanguageIdentifier>` for `unic_langid_impl::LanguageIdentifier`
zbraniecki commented 4 years ago

Thank you for reporting!

Please, use the released version in the meantime - https://crates.io/crates/fluent

zbraniecki commented 4 years ago

oh, I see, sorry. If you're using fluent-bundle 0.9.1, then please use fluent-langneg 0.11 with it and unic-langid 0.7. They were released together.

fluent-langneg 0.11, unic-langid 0.8 are going to be released with fluent-bundle 0.10.

zbraniecki commented 4 years ago

@XAMPPRocky - is this fixed with 0.10 release for you?

XAMPPRocky commented 4 years ago

Yep