XAMPPRocky / fluent-templates

Easily add Fluent to your Rust project.
Apache License 2.0
137 stars 29 forks source link

Example Code for tera does not compile #4

Closed arkN7 closed 4 years ago

arkN7 commented 4 years ago

-> tera.register_function("fluent", FluentLoader::new(&*LOCALES)); Gives away a long error message

-------------------------------------------_ `

error[E0277]: expected a std::ops::Fn<(&std::collections::HashMap<std::string::String, serde_json::value::Value>,)> closure, found fluent_templates::loader::FluentLoader<&fluent_templates::loader::static_loader::StaticLoader> --> src/main.rs:72:38 72 tera.register_function("fluent", FluentLoader::new(&*LOCALES)); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected an Fn<(&std::collections::HashMap<std::string::String, serde_json::value::Value>,)> closure, found fluent_templates::loader::FluentLoader<&fluent_templates::loader::static_loader::StaticLoader>

= help: the trait for<'r> std::ops::Fn<(&'r std::collections::HashMap<std::string::String, serde_json::value::Value>,)> is not implemented for fluent_templates::loader::FluentLoader<&fluent_templates::loader::static_loader::StaticLoader> = note: required because of the requirements on the impl of tera::builtins::functions::Function for fluent_templates::loader::FluentLoader<&fluent_templates::loader::static_loader::StaticLoader>

error[E0277]: expected a std::ops::FnOnce<(&std::collections::HashMap<std::string::String, serde_json::value::Value>,)> closure, found fluent_templates::loader::FluentLoader<&fluent_templates::loader::static_loader::StaticLoader> --> src/main.rs:72:38 72 tera.register_function("fluent", FluentLoader::new(&*LOCALES)); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected an FnOnce<(&std::collections::HashMap<std::string::String, serde_json::value::Value>,)> closure, found fluent_templates::loader::FluentLoader<&fluent_templates::loader::static_loader::StaticLoader>

= help: the trait std::ops::FnOnce<(&std::collections::HashMap<std::string::String, serde_json::value::Value>,)> is not implemented for fluent_templates::loader::FluentLoader<&fluent_templates::loader::static_loader::StaticLoader> = note: required because of the requirements on the impl of tera::builtins::functions::Function for fluent_templates::loader::FluentLoader<&fluent_templates::loader::static_loader::StaticLoader>

`

XAMPPRocky commented 4 years ago

@arkN7 Thank you for your issue! Have you ensured that the tera feature is enabled for fluent-templates?

arkN7 commented 4 years ago

@XAMPPRocky I see, that's the issue, big thanks, now it works!