Skip to content

Conflict with lazy staic #219

@jiashiwen

Description

@jiashiwen

Hi

My lazy_static code is:

lazy_static::lazy_static! {
    static ref GLOBALE_CASBIN_ENFORCER: AsyncOnce<RwLock<CasbinEnforcer>> = AsyncOnce::new(async {
        let ce=CasbinEnforcer::default().await;
        RwLock::new(ce)
    });
}

when i add dependence rsa to my Cargo.yml

[dependencies]
rsa = "0.7.1"

I got Errors

`*const futures_locks::RwLock<CasbinEnforcer>` cannot be sent between threads safely
the trait `std::marker::Send` is not implemented for `*const futures_locks::RwLock<CasbinEnforcer>`
the trait `std::marker::Send` is implemented for `futures_locks::RwLock<T>`
required because of the requirements on the impl of `std::marker::Send` for `Cell<*const futures_locks::RwLock<CasbinEnforcer>>`
required because of the requirements on the impl of `Sync` for `spin::once::Once<AsyncOnce<futures_locks::RwLock<CasbinEnforcer>>>`
shared static variables must have a type that implements `Sync`


`(dyn futures::Future<Output = futures_locks::RwLock<CasbinEnforcer>> + 'static)` cannot be sent between threads safely
the trait `std::marker::Send` is not implemented for `(dyn futures::Future<Output = futures_locks::RwLock<CasbinEnforcer>> + 'static)`
required because of the requirements on the impl of `std::marker::Send` for `Unique<(dyn futures::Future<Output = futures_locks::RwLock<CasbinEnforcer>> + 'static)>`
required because of the requirements on the impl of `std::marker::Send` for `std::sync::Mutex<std::result::Result<futures_locks::RwLock<CasbinEnforcer>, Pin<Box<(dyn futures::Future<Output = futures_locks::RwLock<CasbinEnforcer>> + 'static)>>>>`
required because of the requirements on the impl of `Sync` for `spin::once::Once<AsyncOnce<futures_locks::RwLock<CasbinEnforcer>>>`
shared static variables must have a type that implements `Sync`

Perhaps there is some kind of conflict between the use of future and lazy static in ras

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions