Not support arc?

fluent = “0.16.0”
unic-langid={version=“0.9”,features=[“unic-langid-macros”]}
async-trait = “0.1.51”

use fluent::{FluentBundle, FluentResource};
use unic_langid::langid;
use fluent::resolver::Scope;
use fluent::fluent_args;

#[async_trait::async_trait]
trait Te1{
    async fn test(&self,fluent:FluentBundle<&FluentResource>);
}
struct St1{}
#[async_trait::async_trait]
impl Te1 for St1{
    async fn test(&self,_fluent: FluentBundle<&FluentResource>){

    }
}
fn main() {
    let ftl_string = "hello-world = Hello, world {$aaa}!".to_owned();
    let res = FluentResource::try_new(ftl_string)
        .expect("Failed to parse an FTL string.");

    let langid_en = langid!("en-US");
    let mut bundle = FluentBundle::new(vec![langid_en]);

    bundle.add_resource(&res)
        .expect("Failed to add FTL resources to the bundle.");

    let a=St1{};
    a.test(bundle);
}

error[E0277]: (dyn Any + 'static) cannot be sent between threads safely
–> src/main1.rs:13:64
|
13 | async fn test(&self,_fluent: FluentBundle<&FluentResource>){
| ________________________________________________________________^
14 | |
15 | | }
| |_____^ (dyn Any + 'static) cannot be sent between threads safely
|
= help: the trait Send is not implemented for (dyn Any + 'static)
= note: required because of the requirements on the impl of Send for Unique<(dyn Any + 'static)>
= note: required because it appears within the type Box<(dyn Any + 'static)>
= note: required because it appears within the type (TypeId, Box<(dyn Any + 'static)>)
= note: required because of the requirements on the impl of Send for hashbrown::raw::RawTable<(TypeId, Box<(dyn Any + 'static)>)>
= note: required because it appears within the type hashbrown::map::HashMap<TypeId, Box<(dyn Any + 'static)>, BuildHasherDefault<rustc_hash::FxHasher>>
= note: required because it appears within the type HashMap<TypeId, Box<(dyn Any + 'static)>, BuildHasherDefault<rustc_hash::FxHasher>>
= note: required because it appears within the type Option<HashMap<TypeId, Box<(dyn Any + 'static)>, BuildHasherDefault<rustc_hash::FxHasher>>>
= note: required because it appears within the type type_map::TypeMap
= note: required because of the requirements on the impl of Send for RefCell<type_map::TypeMap>
= note: required because it appears within the type intl_memoizer::IntlLangMemoizer
= note: required because it appears within the type FluentBundle<&FluentResource, intl_memoizer::IntlLangMemoizer>
= note: required because it appears within the type [static generator@src/main1.rs:13:64: 15:6]
= note: required because it appears within the type from_generator::GenFuture<[static generator@src/main1.rs:13:64: 15:6]>
= note: required because it appears within the type impl Future
= note: required for the cast to the object type dyn Future<Output = ()> + Send

See https://docs.rs/fluent-bundle/0.15.1/fluent_bundle/bundle/struct.FluentBundle.html#concurrency

1 Like